-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevserver.js
26 lines (23 loc) · 872 Bytes
/
devserver.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
'use strict';
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const open = require('open');
let config = require('./webpack.config.js');
const port = config.devServer.port;
for (let key in config.entry) {
let entryItem = config.entry[key];
if (key != "common") {
entryItem.unshift("webpack-dev-server/client?http://"+'localhost'+":"+port+"/", "webpack/hot/dev-server");
}
}
config.plugins = config.plugins || [];
config.plugins.push(new webpack.HotModuleReplacementPlugin());
new WebpackDevServer(webpack(config), config.devServer)
.listen(port, '0.0.0.0', (err) => {
if (err) {
console.log(err);
}
console.log('Listening at localhost:' + port);
console.log('Opening your system browser...');
open('http://'+('localhost')+':' + port + '/');
});