1 |
|
2 | 'use strict';
|
3 | const webpack = require('webpack');
|
4 | const WebpackDevServer = require('webpack-dev-server');
|
5 | const open = require('open');
|
6 | const path = require('path');
|
7 | const fs = require('fs');
|
8 |
|
9 | let dllConfig = require('../lib/webpack/webpackConfig')('dll');
|
10 | let compiler = webpack(dllConfig);
|
11 | compiler.run((err, stats) => {
|
12 | if (stats.hasErrors()) {
|
13 | console.log(stats.toString({
|
14 | chunks: false,
|
15 | colors: true
|
16 | }));
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 | let config = require(path.join(__dirname, '../lib/webpack/buildTypes/devServer'));
|
22 |
|
23 | let extendablePath = path.join(`${__dirname}/../../../tools/` + 'webpackConfig.js');
|
24 | if (fs.existsSync(extendablePath)) {
|
25 | config = require(extendablePath)(config);
|
26 | }
|
27 |
|
28 | new WebpackDevServer(webpack(config), config.devServer)
|
29 | .listen(config.devServer.port, '0.0.0.0', (err) => {
|
30 | if (err) {
|
31 | console.log(err);
|
32 | }
|
33 | console.log(`Listening at localhost:${config.devServer.port}`);
|
34 | console.log('Opening your system browser...');
|
35 | open(`http://localhost:${config.devServer.port}/`);
|
36 | });
|
37 | });
|
38 |
|