Skip to content

Commit

Permalink
Exit production build if any errors are in build stats (facebook#859)
Browse files Browse the repository at this point in the history
* Exit on any errors passed in build stats

* Match console error output in start.js
  • Loading branch information
pdillon authored and feiqitian committed Oct 25, 2016
1 parent d7bdab6 commit 8e99095
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
function build(previousSizeMap) {
console.log('Creating an optimized production build...');
webpack(config).run((err, stats) => {
if (err) {
console.error('Failed to create a production build. Reason:');
console.error(err.message || err);
printErrors('Failed to compile.', [err]);
process.exit(1);
}

if (stats.compilation.errors.length) {
printErrors('Failed to compile.', stats.compilation.errors);
process.exit(1);
}

Expand Down

0 comments on commit 8e99095

Please sign in to comment.