Created
December 22, 2018 00:47
-
-
Save jonesmac/9ef456153c714db56be0ec24b61c6fbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This plugin makes sure karma doesn't run any specs when there's a | |
* compilation error in a module by checking the finished compilation for warnings | |
* which would prevent tests from accurately running. | |
* | |
* Inspiration for looking at the warnings length | |
* https://gist.github.com/Stuk/6b574049435df532e905 | |
*/ | |
import { Compiler } from 'webpack'; | |
export class WebpackKarmaWarningsPlugin { | |
public apply(compiler: Compiler) { | |
compiler.hooks.emit.tapAsync( | |
'WebpackKarmaWarningsPlugin', | |
(compilation, callback) => { | |
if (compilation.warnings.length) { | |
throw new Error(compilation.warnings.toString()); | |
} | |
callback(); | |
} | |
); | |
} | |
} |
This no longer works with Webpack 5 😭
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
Great work sir. I am sooo close, but the apply() function is giving me a bit of an issue adding the plugin when npm/webpack build is performed:
webpack.config.js:
Here is a slight modification to the .ts:
Please advise.