Reputation: 41
When I use webpack
in nodejs
, it can catch every compile error, the watching callback will be called every build end.
const webpack = require("webpack");
const compiler = webpack({
// Configuration Object
});
const watching = compiler.watch({
/* watchOptions */
}, (err, stats) => {
// Print watch/build result here...
console.log(stats);
});
But when I use webpack-dev-server
, the listen callback only called once when the server started, its there any way to catch every compile error when use webpack-dev-server
in nodejs
?
const compiler = Webpack(webpackConfig);
const server = new WebpackDevServer(compiler, {
stats: {
colors: true
}
});
server.listen(8080, '127.0.0.1', () => {
// only called once
console.log('bla');
});
Upvotes: 2
Views: 1782
Reputation: 41
finally solved this problem with plugin
compiler.plugin('done',callback)
this callback will be called every build done.
Upvotes: 1