当我在webpack
中使用nodejs
时,它可以捕获每个编译错误,每次构建结束时都会调用观看回调。
const webpack = require("webpack");
const compiler = webpack({
// Configuration Object
});
const watching = compiler.watch({
/* watchOptions */
}, (err, stats) => {
// Print watch/build result here...
console.log(stats);
});
但是当我使用webpack-dev-server
时,监听回调只在服务器启动时调用一次,在webpack-dev-server
中使用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');
});
答案 0 :(得分:1)
终于用插件解决了这个问题
,Call to a member function getClientOriginalName() on array
每次构建完成后都会调用此回调。