Skip to content

Commit 49c236d

Browse files
committed
Show webpack validation errors nicely
Fixes #653
1 parent 0ceabc6 commit 49c236d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bin/webpack-dev-server.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,20 @@ function processOptions(wpOpt) {
307307
});
308308
}
309309

310-
var compiler = webpack(wpOpt);
310+
var compiler;
311+
try {
312+
compiler = webpack(wpOpt);
313+
} catch(e) {
314+
var WebpackOptionsValidationError = require("webpack/lib/WebpackOptionsValidationError");
315+
if(e instanceof WebpackOptionsValidationError) {
316+
if(options.stats.colors)
317+
console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
318+
else
319+
console.error(e.message);
320+
process.exit(1); // eslint-disable-line
321+
}
322+
throw e;
323+
}
311324

312325
if(argv["progress"]) {
313326
compiler.apply(new webpack.ProgressPlugin({

0 commit comments

Comments
 (0)