diff --git a/README.md b/README.md index 1cb8946..b203fcf 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Arguments: * `test`: All assets matching this RegExp are processed. Defaults to every asset. * `threshold`: Only assets bigger than this size are processed. In bytes. Defaults to `0`. * `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`. +* `deleteOriginalAssets`: Whether to delete the original assets or not. Defaults to `false`. Option Arguments for Zopfli (see [node-zopfli](https://github.com/pierreinglebert/node-zopfli#options) doc for details): * verbose: Default: false, diff --git a/index.js b/index.js index 79a918a..ae51bc9 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,7 @@ function CompressionPlugin(options) { this.test = options.test || options.regExp; this.threshold = options.threshold || 0; this.minRatio = options.minRatio || 0.8; + this.deleteOriginalAssets = options.deleteOriginalAssets || false; } module.exports = CompressionPlugin; @@ -80,6 +81,9 @@ CompressionPlugin.prototype.apply = function(compiler) { return sub[p1]; }); assets[newFile] = new RawSource(result); + if (this.deleteOriginalAssets) { + delete assets[file]; + } callback(); }.bind(this)); }.bind(this), callback);