Skip to content

Instantly share code, notes, and snippets.

@matt-hensley
Created November 10, 2016 15:20
Show Gist options
  • Save matt-hensley/46ae283b6a84c5a5bf7f3c0b98daa8f0 to your computer and use it in GitHub Desktop.
Save matt-hensley/46ae283b6a84c5a5bf7f3c0b98daa8f0 to your computer and use it in GitHub Desktop.
var SuppressWarningPlugin = function (warningName, moduleName) {
this.warningName = warningName;
this.moduleName = moduleName;
};
SuppressWarningPlugin.prototype.apply = function (compiler) {
var warningName = this.warningName;
var moduleName = this.moduleName;
compiler.plugin("emit", function (compilation, callback) {
if (compilation && compilation.warnings && compilation.warnings.length) {
compilation.warnings = compilation.warnings.filter(function (warning) {
if (warning.name !== warningName) return true;
return !(warning.origin && warning.origin.rawRequest === moduleName);
});
}
callback();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment