Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 24f15f2

Browse files
stijnvnjoshwiens
authored andcommitted
feat: add option to delete original assets (#44)
1 parent 31e9304 commit 24f15f2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Arguments:
4242
* `test`: All assets matching this RegExp are processed. Defaults to every asset.
4343
* `threshold`: Only assets bigger than this size are processed. In bytes. Defaults to `0`.
4444
* `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`.
45+
* `deleteOriginalAssets`: Whether to delete the original assets or not. Defaults to `false`.
4546

4647
Option Arguments for Zopfli (see [node-zopfli](https://github.com/pierreinglebert/node-zopfli#options) doc for details):
4748
* verbose: Default: false,

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function CompressionPlugin(options) {
4848
this.test = options.test || options.regExp;
4949
this.threshold = options.threshold || 0;
5050
this.minRatio = options.minRatio || 0.8;
51+
this.deleteOriginalAssets = options.deleteOriginalAssets || false;
5152
}
5253
module.exports = CompressionPlugin;
5354

@@ -80,6 +81,9 @@ CompressionPlugin.prototype.apply = function(compiler) {
8081
return sub[p1];
8182
});
8283
assets[newFile] = new RawSource(result);
84+
if (this.deleteOriginalAssets) {
85+
delete assets[file];
86+
}
8387
callback();
8488
}.bind(this));
8589
}.bind(this), callback);

0 commit comments

Comments
 (0)