Skip to content

Commit e107cc5

Browse files
committed
allow to filter uglify warnings by adding option "warningsFilter"
only works if "sourceMap" setting is true
1 parent b7d0155 commit e107cc5

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

lib/optimize/UglifyJsPlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class UglifyJsPlugin {
2121
apply(compiler) {
2222
let options = this.options;
2323
options.test = options.test || /\.js($|\?)/i;
24+
const warningsFilter = options.warningsFilter || (() => true);
2425

2526
let requestShortener = new RequestShortener(compiler.context);
2627
compiler.plugin("compilation", (compilation) => {
@@ -66,6 +67,7 @@ class UglifyJsPlugin {
6667
column: column
6768
});
6869
if(!original || !original.source || original.source === file) return;
70+
if(!warningsFilter(original.source)) return;
6971
warnings.push(warning.replace(/\[.+:([0-9]+),([0-9]+)\]/, "") +
7072
"[" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "]");
7173
};

0 commit comments

Comments
 (0)