Skip to content

Commit

Permalink
(feat): add webpack validation error logging (facebook#1596)
Browse files Browse the repository at this point in the history
* (feat): add webpack validation error logging

* Style nit

* Style tweak

* Style nit
  • Loading branch information
johann-sonntagbauer authored and gaearon committed Feb 24, 2017
1 parent db12544 commit 46f729b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,16 @@ function printErrors(summary, errors) {
// Create the production build and print the deployment instructions.
function build(previousSizeMap) {
console.log('Creating an optimized production build...');
webpack(config).run((err, stats) => {

var compiler;
try {
compiler = webpack(config);
} catch (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
}

compiler.run((err, stats) => {
if (err) {
printErrors('Failed to compile.', [err]);
process.exit(1);
Expand Down
10 changes: 9 additions & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ if (isSmokeTest) {
function setupCompiler(host, port, protocol) {
// "Compiler" is a low-level interface to Webpack.
// It lets us listen to some events and provide our own custom messages.
compiler = webpack(config, handleCompile);
try {
compiler = webpack(config, handleCompile);
} catch (err) {
console.log(chalk.red('Failed to compile.'));
console.log();
console.log(err.message || err);
console.log();
process.exit(1);
}

// "invalid" event fires when you have changed a file, and Webpack is
// recompiling a bundle. WebpackDevServer takes care to pause serving the
Expand Down

0 comments on commit 46f729b

Please sign in to comment.