forked from songkai2012/webpack_multiPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (24 loc) · 869 Bytes
/
server.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
const Server = require("./server/serverModule");
const config = require("./server/config");
const router = require("./server/router/controller.js");
const app = Server.app();
if(process.env.NODE_ENV=='server'){
const webpack = require("webpack");
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpackConfig = require("./webpack.config");
//webpackConfig.plugins.push(webpackHotMiddleware);
const compiler = webpack(webpackConfig);
app.use(webpackHotMiddleware(compiler));
app.use(webpackDevMiddleware(compiler,{
noInfo:true,
stats: {
colors: true
},
publicPath:webpackConfig.output.publicPath
}));
}else {
}
app.use('/',router);
app.listen(config.port);
console.log(`Listen at port ${config.port}`);