diff --git a/packages/neutrino/commands/build/index.js b/packages/neutrino/commands/build/index.js index 336bec3..0c285ba 100644 --- a/packages/neutrino/commands/build/index.js +++ b/packages/neutrino/commands/build/index.js @@ -4,25 +4,43 @@ const getPreset = require('../../src/get-preset'); const DevServer = require('webpack-dev-server'); const webpack = require('webpack'); +const handleErrors = (err, stats) => { + if (err) { + console.error(err.stack || err); + + if (err.details) { + console.error(err.details); + } + + return true; + } + + const jsonStats = stats.toJson(); + + if (jsonStats.errors.length) { + jsonStats.errors.map(err => console.error(err)); + return true; + } + + return false; +}; + const build = (config, done) => { const compiler = webpack(config); compiler.run((err, stats) => { - if (!err) { - console.log(stats.toString({ - colors: true, - chunks: false, - children: false - })); - } else { - console.error(err.stack || err); - - if (err.details) { - console.error(err.details); - } + const failed = handleErrors(err, stats); + + if (failed) { + return done(1); } - done(); + console.log(stats.toString({ + colors: true, + chunks: false, + children: false + })); + done(0); }); }; diff --git a/packages/neutrino/package.json b/packages/neutrino/package.json index 037c921..a90812b 100644 --- a/packages/neutrino/package.json +++ b/packages/neutrino/package.json @@ -1,6 +1,6 @@ { "name": "neutrino", - "version": "2.1.0", + "version": "2.2.0", "description": "Create and build JS applications with managed configurations", "main": "bin/neutrino", "bin": { @@ -52,7 +52,7 @@ "resolve": "1.1.7", "vorpal": "1.4.1", "webpack": "1.13.2", - "webpack-dev-server": "1.15.2", + "webpack-dev-server": "1.16.2", "webpack-hot-middleware": "2.12.2", "webpack-merge": "0.14.1", "yeoman-environment": "1.6.3"