-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (24 loc) · 1.07 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
const open = require('open');
const webpack = require('webpack');
const internalIP = require('internal-ip');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config.js');
const portal = config.devServer.https ? 'https' : 'http';
const port = config.devServer.port;
const ip = internalIP.v4.sync();
for (let key in config.entry) {
let ar = config.entry[key];
if (key != "common" && key != "manifest") {
ar.unshift("webpack-dev-server/client?" + portal + "://" + ip + ":" + port + "/", "webpack/hot/dev-server");
}
}
config.plugins = config.plugins || [];
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.plugins.push(new webpack.NamedModulesPlugin());
new WebpackDevServer(webpack(config), config.devServer)
.listen(port, ip, (err) => {
if (err) { console.log(err); }
console.log('Listening at localhost:' + port);
console.log('Opening your system browser...');
open(portal + '://' + (ip || '127.0.0.1') + ':' + port + '/static/index.html?debug=true');
});