This repository has been archived by the owner on Apr 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c9f6a97
Showing
37 changed files
with
650 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
write: true, | ||
prefix: '^', | ||
test: [ | ||
'test', | ||
'benchmark', | ||
], | ||
dep: [ | ||
], | ||
devdep: [ | ||
'egg-ci', | ||
'egg-bin', | ||
'autod', | ||
'eslint', | ||
'eslint-config-egg', | ||
'webstorm-disable-index', | ||
], | ||
exclude: [ | ||
'./test/fixtures', | ||
'./dist', | ||
], | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "presets": [ "es2015" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "eslint-config-egg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
logs/ | ||
npm-debug.log | ||
node_modules/ | ||
coverage/ | ||
.idea/ | ||
run/ | ||
.DS_Store | ||
*.swp | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- '6' | ||
install: | ||
- npm i npminstall && npminstall | ||
script: | ||
- npm run ci | ||
after_script: | ||
- npminstall codecov && codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# egg-multi-boilerplate | ||
|
||
eggjs 的 boilerplate 项目 | ||
综合了webpack,browserSync的多页应用配置 | ||
|
||
|
||
## 快速入门 | ||
|
||
|
||
如需进一步了解,参见 [egg 文档][egg]。 | ||
|
||
### 本地开发 | ||
```bash | ||
$ npm install | ||
$ npm run dev | ||
$ open http://localhost:7001/news | ||
``` | ||
|
||
### 部署 | ||
|
||
线上正式环境用 `EGG_SERVER_ENV=prod` 来启动。 | ||
|
||
```bash | ||
$ EGG_SERVER_ENV=prod npm start | ||
``` | ||
|
||
### 单元测试 | ||
- [egg-bin] 内置了 [mocha], [thunk-mocha], [power-assert], [istanbul] 等框架,让你可以专注于写单元测试,无需理会配套工具。 | ||
- 断言库非常推荐使用 [power-assert]。 | ||
- 具体参见 [egg 文档 -单元测试](https://eggjs.org/zh-cn/core/unittest)。 | ||
|
||
### 内置指令 | ||
|
||
- 使用 `npm run lint` 来做代码风格检查。 | ||
- 使用 `npm test` 来执行单元测试。 | ||
- 使用 `npm run autod` 来自动检测依赖更新,详细参见 [autod](https://www.npmjs.com/package/autod) 。 | ||
|
||
|
||
[egg]: https://eggjs.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
module.exports = app => { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
module.exports = app => { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
class HomeController extends app.Controller { | ||
* index() { | ||
const data = { name: 'egg' }; | ||
yield this.ctx.render('home/index', data); | ||
} | ||
|
||
* about() { | ||
const data = { name: 'about' }; | ||
yield this.ctx.render('about/index', data); | ||
} | ||
} | ||
return HomeController; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// this 是 helper 对象,在其中可以调用其他 helper 方法 | ||
// this.ctx => context 对象 | ||
// this.app => application 对象 | ||
const manifest = require('../../dist/manifest.json'); | ||
const url = require('url'); | ||
|
||
exports.Loader = function (resource) { | ||
resource = manifest[resource +'.js'] | ||
return resource | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// this 是 helper 对象,在其中可以调用其他 helper 方法 | ||
// this.ctx => context 对象 | ||
// this.app => application 对象 | ||
const url = require('url'); | ||
|
||
exports.Loader = function (resource) { | ||
const publicPath = this.app.config.browsersync.options.publicPath; | ||
return url.resolve(publicPath,resource+'.js') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import './index.less' | ||
import {bar} from '../common/index' | ||
|
||
console.log('i am about' + bar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body{ | ||
background-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const foo = 1; | ||
export const bar = 2; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import './index.less' | ||
import {foo} from '../common/index' | ||
|
||
console.log('i am home' + foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body{ | ||
background-color: green; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = app => { | ||
app.get('/', 'home.index'); | ||
app.get('/about', 'home.about'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "../layout/base.nj" %} | ||
|
||
{% block body %} | ||
<div> | ||
page about ! | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script src="{{ helper.Loader('about') }}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "../layout/base.nj" %} | ||
|
||
{% block body %} | ||
<div> | ||
page home ! | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script src="{{ helper.Loader('home') }}"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title!!</title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<h1>hello world!!!!</h1> | ||
<p @click="doSomething">test ${message}</p> | ||
</div> | ||
<p>egg name: {{name}} | ||
</p> | ||
<p> | ||
Loader: {{helper.Loader('home')}} | ||
</p> | ||
<script src="https://cdn.bootcss.com/vue/2.3.0/vue.min.js"></script> | ||
<script src="{{helper.Loader('home')}}"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Title</title> | ||
|
||
{% block header %} | ||
This is the default content | ||
{% endblock %} | ||
</head> | ||
<body> | ||
{% block body %} | ||
This is the default content | ||
{% endblock %} | ||
|
||
<script src="https://cdn.bootcss.com/vue/2.3.0/vue.min.js"></script> | ||
{% block js %} | ||
This is the default content | ||
{% endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
environment: | ||
matrix: | ||
- nodejs_version: '6' | ||
|
||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- npm i npminstall && node_modules\.bin\npminstall | ||
|
||
test_script: | ||
- node --version | ||
- npm --version | ||
- npm run ci | ||
|
||
build: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const path = require("path"); | ||
const webpack = require('webpack'); | ||
const webpackDevMiddleware = require('webpack-dev-middleware'); | ||
const webpackHotMiddleware = require('webpack-hot-middleware'); | ||
|
||
// return a function to ge bs config | ||
module.exports = (config) => { | ||
const {port,publicPath} = config; | ||
const webpackConfig = require('./webpack.dev.config'); | ||
webpackConfig.output.publicPath = publicPath; | ||
|
||
// Add the client which connects to our middleware | ||
// You can use full urls like 'webpack-hot-middleware/client?path=http://localhost:3000/__webpack_hmr' | ||
// useful if you run your app from another point like django | ||
const hotSet = `webpack-hot-middleware/client?path=http://localhost:${port}/__webpack_hmr&timeout=2000&overlay=false&reload=true` | ||
// add dev-server entry | ||
Object.keys(webpackConfig.entry).forEach(name => { | ||
if (!/\./.test(name)) { | ||
webpackConfig.entry[name] = [hotSet].concat(webpackConfig.entry[name]); | ||
} | ||
}); | ||
|
||
const bundler = webpack(webpackConfig); | ||
|
||
return { | ||
init: true, | ||
files: [ | ||
"app/view/**/*", | ||
// "app/public/**/*" | ||
], | ||
logConnections: false, | ||
|
||
port, // bs 启动的端口 | ||
|
||
middleware: [ | ||
webpackDevMiddleware(bundler, { | ||
// IMPORTANT: dev middleware can't access config, so we should | ||
// provide publicPath by ourselves | ||
publicPath: webpackConfig.output.publicPath, | ||
|
||
// pretty colored output | ||
stats: {colors: true}, | ||
|
||
headers: { | ||
'X-information': 'egg-webpack-dev-server', | ||
'Access-Control-Allow-Origin': '*', | ||
} | ||
|
||
// for other settings see | ||
// http://webpack.github.io/docs/webpack-dev-middleware.html | ||
}), | ||
|
||
// bundler should be the same as above | ||
webpackHotMiddleware(bundler, { | ||
log: false, | ||
path: "/__webpack_hmr", | ||
heartbeat: 2000 | ||
}) | ||
] | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
context: path.resolve(__dirname, '../'), | ||
|
||
entry: { | ||
// Add the client which connects to our middleware | ||
home: ['./app/public/home/index.js'], | ||
about: ['./app/public/about/index.js'], | ||
}, | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const webpack = require('webpack'); | ||
const path = require('path'); | ||
const merge = require('webpack-merge'); | ||
const baseConfig = require('./webpack.base.config'); | ||
|
||
const devConfig = { | ||
|
||
output: { | ||
// path: path.resolve(__dirname, '../dist'), | ||
// publicPath: '/public/', | ||
filename: '[name].js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
include: path.resolve(__dirname, '../app'), | ||
// exclude: /node_modules/, | ||
loader: 'babel-loader', | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
], | ||
}, | ||
{ | ||
test: /\.less$/i, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
"less-loader" | ||
], | ||
}, | ||
], | ||
}, | ||
devtool: '#source-map', | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new webpack.NamedModulesPlugin(), | ||
], | ||
}; | ||
|
||
module.exports = merge(baseConfig,devConfig); |
Oops, something went wrong.