UNPKG

974 BJavaScriptView Raw
1var WebpackWatchConfig = require('../config/webpack.config.watch');
2
3var setupCompiler = require('./setupCompiler');
4var printErrors = require('./printErrors');
5
6module.exports = function (config, dllConfig, callback) {
7 var webpackConfig = WebpackWatchConfig(config, dllConfig);
8 var webpackCompiler = setupCompiler(webpackConfig);
9 console.log();
10 console.log('> ' + Object.keys(webpackConfig.entry).join(', ') + ' building...');
11 console.log();
12
13 webpackCompiler.watch({
14 aggregateTimeout: 300
15 }, (err, stats) => {
16 if (err) {
17 printErrors('Failed to compile.', [err]);
18 process.exit(1);
19 }
20
21 if (stats.compilation.errors.length) {
22 printErrors('Failed to compile.', stats.compilation.errors);
23 process.exit(1);
24 }
25
26 if (process.env.CI && stats.compilation.warnings.length) {
27 printErrors('Failed to compile.', stats.compilation.warnings);
28 process.exit(1);
29 }
30
31 callback && callback(webpackConfig);
32 });
33};