forked from seebox/BoxWebApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (31 loc) · 1.14 KB
/
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
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config.dev');
var app_config = require('./appconfig.js');
var devServer = app_config.getDevServer();
var compiler = webpack(config);
console.log('Starting Webpack Dev Server....');
var cmdport = Number.isInteger(Number.parseInt(process.argv[3]))?process.argv[3]:(Number.isInteger(Number.parseInt(process.argv[2]))?process.argv[2]:devServer.port);
var proxyCfg = {};
proxyCfg[app_config.defaultDevServer.apiBashPath] = {
target: app_config.defaultDevServer.apiAddress,
secure: false,
rewrite: function(req, proxyOptions){
proxyOptions.host=app_config.defaultDevServer.apiHost;
}
};
var devServerInstance = new WebpackDevServer(compiler, {
publicPath: config.output.publicPath,
hot: true,
noInfo: true,
colors: true,
historyApiFallback: true,
proxy: proxyCfg
});
devServerInstance.listen(cmdport, '0.0.0.0', function(err, result) {
if (err) {
console.log(err);
}
console.log('Listening at ' + devServer.hostname + ':' + cmdport);
console.log('Access address: http://' + devServer.ip + ':' + cmdport);
});