NoEmitOnErrorsPlugin.js 713 B

12345678910111213141516171819202122232425262728
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("./Compiler")} Compiler */
  7. class NoEmitOnErrorsPlugin {
  8. /**
  9. * Apply the plugin
  10. * @param {Compiler} compiler the compiler instance
  11. * @returns {void}
  12. */
  13. apply(compiler) {
  14. compiler.hooks.shouldEmit.tap("NoEmitOnErrorsPlugin", compilation => {
  15. if (compilation.getStats().hasErrors()) return false;
  16. });
  17. compiler.hooks.compilation.tap("NoEmitOnErrorsPlugin", compilation => {
  18. compilation.hooks.shouldRecord.tap("NoEmitOnErrorsPlugin", () => {
  19. if (compilation.getStats().hasErrors()) return false;
  20. });
  21. });
  22. }
  23. }
  24. module.exports = NoEmitOnErrorsPlugin;