-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
40 lines (28 loc) · 973 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require('babel-core/register'); // 改写 require 钩子函数
require('babel-polyfill'); // 针对一些 ES6+ 新增 API 进行 polyfill
const Koa = require('koa');
const logger = require('koa-logger');
const views = require('koa-views');
const serve = require('koa-static');
const path = require('path');
const rootRouter = require('./router/root.js');
const userRouter = require('./router/user.js');
const app = module.exports = new Koa();
app.use(logger());
app.use(views(path.join(__dirname, '/views'), {
extension: 'ejs'
}));
app.use(serve(path.join(__dirname, '/public')));
app
.use(rootRouter.routes())
.use(rootRouter.allowedMethods())
.use(userRouter.routes())
.use(userRouter.allowedMethods());
let Webpack = require('webpack');
let middleware = require('koa-webpack');
let config = require('./webpack.config.js');
const compiler = Webpack(config);
app.use(middleware({
config: config
}))
if (!module.parent) app.listen(3000);