UNPKG

1.26 kBJavaScriptView Raw
1/* eslint no-console:0 */
2'use strict';
3const webpack = require('webpack');
4const WebpackDevServer = require('webpack-dev-server');
5const open = require('open');
6const path = require('path');
7const fs = require('fs');
8
9let dllConfig = require('../lib/webpack/webpackConfig')('dll');
10let compiler = webpack(dllConfig);
11compiler.run((err, stats) => {
12 if (stats.hasErrors()) {
13 console.log(stats.toString({
14 chunks: false, // Makes the build much quieter
15 colors: true // Shows colors in the console
16 }));
17 }
18
19// this is the dev server webpack configuration
20// in short, production is not the right name of the 'env'....
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