webpack/lib/NoEmitOnErrorsPlugin.js

31 lines
729 B
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
2018-07-30 23:08:51 +08:00
"use strict";
2018-11-03 04:05:46 +08:00
/** @typedef {import("./Compiler")} Compiler */
2025-04-23 20:03:37 +08:00
const PLUGIN_NAME = "NoEmitOnErrorsPlugin";
class NoEmitOnErrorsPlugin {
2018-11-03 04:05:46 +08:00
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.shouldEmit.tap(PLUGIN_NAME, (compilation) => {
2018-02-25 09:00:20 +08:00
if (compilation.getStats().hasErrors()) return false;
});
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
2025-04-23 20:03:37 +08:00
compilation.hooks.shouldRecord.tap(PLUGIN_NAME, () => {
2018-02-25 09:00:20 +08:00
if (compilation.getStats().hasErrors()) return false;
});
});
}
}
module.exports = NoEmitOnErrorsPlugin;