mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 05:05:53 +08:00
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
This commit is contained in:
committed by
Dan Abramov
parent
410a6a957a
commit
c6428eaff9
18
packages/react-scripts/scripts/build.js
vendored
18
packages/react-scripts/scripts/build.js
vendored
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user