Skip to content

Commit f16eb95

Browse files
committed
Show compilation warnings when building
1 parent 022822b commit f16eb95

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

packages/react-scripts/scripts/build.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ function printErrors(summary, errors) {
6262
});
6363
}
6464

65+
function printWarnings(summary, warnings) {
66+
console.log(chalk.yellow(summary));
67+
console.log();
68+
warnings.forEach(err => {
69+
console.log(err.message || err);
70+
console.log();
71+
});
72+
}
73+
6574
// Create the production build and print the deployment instructions.
6675
function build(previousFileSizes) {
6776
console.log('Creating an optimized production build...');
@@ -77,12 +86,17 @@ function build(previousFileSizes) {
7786
}
7887

7988
if (process.env.CI && stats.compilation.warnings.length) {
80-
printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
81-
process.exit(1);
82-
}
89+
printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
90+
process.exit(1);
91+
}
8392

84-
console.log(chalk.green('Compiled successfully.'));
85-
console.log();
93+
if (stats.compilation.warnings.length) {
94+
console.log();
95+
printWarnings('Compiled with warnings.', stats.compilation.warnings);
96+
} else {
97+
console.log(chalk.green('Compiled successfully.'));
98+
console.log();
99+
}
86100

87101
console.log('File sizes after gzip:');
88102
console.log();

0 commit comments

Comments
 (0)