-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.start.js
More file actions
37 lines (29 loc) · 886 Bytes
/
webpack.start.js
File metadata and controls
37 lines (29 loc) · 886 Bytes
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
const WebpackStart = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
let params = process.argv.slice(2);
let env = {};
params.forEach(param => {
let index = param.indexOf("=");
if (index >= 0) {
let key = param.substring(0, index);
env[key] = param.substring(index + 1);
} else {
env[param] = true;
}
});
console.log(env);
const webpackConfig = require('./webpack.config.js')(env);
const compiler = WebpackStart(webpackConfig);
const devServerOptions = {...webpackConfig.devServer};
const server = new WebpackDevServer(devServerOptions, compiler);
const runServer = async () => {
console.log('Starting server...');
await server.start();
};
// const stopServer = async () => {
// console.log('Stopping server...');
// await server.stop();
// };
(async function () {
await runServer();
})();