From 43014e87ecdbb342ab1fe7a6e0d4b48ebd10cb4b Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Wed, 5 Oct 2016 21:23:22 -0400 Subject: [PATCH 1/2] Exit on any errors passed in build stats --- packages/react-scripts/scripts/build.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 4c61dc93ba7..fc3e695ab3f 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -128,6 +128,13 @@ function build(previousSizeMap) { process.exit(1); } + // Webpack may swallow uglify errors even with bail:true + if (stats.compilation.errors.length) { + console.error(chalk.red('Error(s) occurred during the production build:')); + stats.compilation.errors.forEach(err => console.error(chalk.red(err.message || err))); + process.exit(1); + } + console.log(chalk.green('Compiled successfully.')); console.log(); From 93e4c291daaa99801a21bf0f7f2a453d0c412307 Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Fri, 7 Oct 2016 09:52:52 -0400 Subject: [PATCH 2/2] Match console error output in start.js --- packages/react-scripts/scripts/build.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index fc3e695ab3f..d0b92f6a73b 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -118,20 +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); } - // Webpack may swallow uglify errors even with bail:true if (stats.compilation.errors.length) { - console.error(chalk.red('Error(s) occurred during the production build:')); - stats.compilation.errors.forEach(err => console.error(chalk.red(err.message || err))); + printErrors('Failed to compile.', stats.compilation.errors); process.exit(1); }