webpack/lib/NoEmitOnErrorsPlugin.js

29 lines
713 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 */
class NoEmitOnErrorsPlugin {
2018-11-03 04:05:46 +08:00
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
2018-02-25 09:00:20 +08:00
compiler.hooks.shouldEmit.tap("NoEmitOnErrorsPlugin", compilation => {
if (compilation.getStats().hasErrors()) return false;
});
2018-02-25 09:00:20 +08:00
compiler.hooks.compilation.tap("NoEmitOnErrorsPlugin", compilation => {
2017-12-06 22:01:25 +08:00
compilation.hooks.shouldRecord.tap("NoEmitOnErrorsPlugin", () => {
2018-02-25 09:00:20 +08:00
if (compilation.getStats().hasErrors()) return false;
});
});
}
}
module.exports = NoEmitOnErrorsPlugin;