angular-cli/packages/@angular/cli/plugins/karma-webpack-throw-error.ts
2017-03-20 09:10:17 -07:00

15 lines
471 B
TypeScript

// Force Webpack to throw compilation errors. Useful with karma-webpack when in single-run mode.
// Workaround for https://github.com/webpack-contrib/karma-webpack/issues/66
export class KarmaWebpackThrowError {
constructor() { }
apply(compiler: any): void {
compiler.plugin('done', (stats: any) => {
if (stats.compilation.errors.length > 0) {
throw new Error(stats.compilation.errors.map((err: any) => err.message || err));
}
});
}
}