Commit c6428eaf authored by Patrick Dillon's avatar Patrick Dillon Committed by Dan Abramov
Browse files

Exit production build if any errors are in build stats (#859)

* Exit on any errors passed in build stats

* Match console error output in start.js
parent 410a6a95
No related merge requests found
Showing with 16 additions and 2 deletions
+16 -2
...@@ -118,13 +118,27 @@ function printFileSizes(stats, previousSizeMap) { ...@@ -118,13 +118,27 @@ function printFileSizes(stats, previousSizeMap) {
}); });
} }
// Print out errors
function printErrors(summary, errors) {
console.log(chalk.red(summary));
console.log();
errors.forEach(err => {
console.log(err.message || err);
console.log();
});
}
// Create the production build and print the deployment instructions. // Create the production build and print the deployment instructions.
function build(previousSizeMap) { function build(previousSizeMap) {
console.log('Creating an optimized production build...'); console.log('Creating an optimized production build...');
webpack(config).run((err, stats) => { webpack(config).run((err, stats) => {
if (err) { if (err) {
console.error('Failed to create a production build. Reason:'); printErrors('Failed to compile.', [err]);
console.error(err.message || err); process.exit(1);
}
if (stats.compilation.errors.length) {
printErrors('Failed to compile.', stats.compilation.errors);
process.exit(1); process.exit(1);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment