1、原理
compiler 在每次构建结束后会触发 done 这 个 hook;
函数插件,内部this指向
compiler ;
2、编码
function() {
this.hooks.done.tap('done', (stats) => {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1)
{
console.log('build error');
process.exit(1);
}
})
}