-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
26 lines (24 loc) · 880 Bytes
/
start.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
var webpack = require('webpack');
var webpackConfig = require('./webpack.config');
var webpackDevServer = require('webpack-dev-server');
var detect = require('detect-port');
function startWebpackDevServer() {
port = webpackConfig.devServer.port;
detect(port)
.then(_port => {
const devServerOptions = Object.assign({}, webpackConfig.devServer, {
open: true,
port: _port,
public: 'localhost:' + _port,
publicPath: '/dist',
});
webpackConfig.devServer = devServerOptions;
const compiler = webpack(webpackConfig);
const server = new webpackDevServer(compiler, devServerOptions);
server.listen(_port, '127.0.0.1', () => {});
})
.catch(err => {
console.log(err);
});
}
+startWebpackDevServer();