-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (29 loc) · 894 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
29
30
31
32
33
34
35
36
37
38
39
40
41
const webpackConfig = require('./webpack.config.js');
const webpack = require('webpack');
const express = require('express');
const app = express();
// 处理mode:'history'下的地址问题
var history = require('connect-history-api-fallback');
app.use(history({
index: '/',
verbose: true,
}));
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var compiler = webpack(webpackConfig);
var devMiddleware = webpackDevMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
hot: true,
noInfo: true,
quiet: true, //向控制台显示任何内容
stats: {
colors: true,
chunks: false
}
});
var hotMiddleware = webpackHotMiddleware(compiler);
app.use(devMiddleware);
app.use(hotMiddleware);
app.listen(3000, function(req, res) {
console.log('listening on port 3000!');
});