-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack-dev-server.js
45 lines (38 loc) · 1018 Bytes
/
webpack-dev-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
42
43
44
45
process.env.ENVIRONMENT = 'local';
let config = require('./webpack.config.js');
let webpack = require('webpack');
let WebpackDevServer = require('webpack-dev-server');
let Dashboard = require('webpack-dashboard');
let DashboardPlugin = require('webpack-dashboard/plugin');
let api_server_url = 'http://localhost:4396/';
let compiler = webpack(config);
let isWin = /^win/.test(process.platform);
if (!isWin) {
let dashboard = new Dashboard();
compiler.apply(new DashboardPlugin(dashboard.setData));
}
let server = new WebpackDevServer(compiler, {
contentBase: './public',
quiet: !isWin,
lazy: false,
stats: {
colors: true,
},
proxy: {
'/api/*': {
target: api_server_url,
pathRewrite: { '^/api': '' },
secure: false,
},
'**': {
target: api_server_url,
secure: false,
bypass(req, res, proxyOptions) {
if (req.headers.accept.indexOf('html') !== -1) {
return '/index.html';
}
},
},
},
});
server.listen(8999);