Skip to content

Commit 78380e0

Browse files
rufmanjoshwiens
authored andcommitted
refactor: Expose zopfli compression options
1 parent 2c22b1c commit 78380e0

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ module.exports = {
2020
Arguments:
2121

2222
* `asset`: The target asset name. `{file}` is replaced with the original asset. Defaults to `"{file}.gz"`.
23-
* `algorithm`: Can be a `function(buf, callback)` or a string. For a string the algorithm is tacken from `zlib`. Defaults to `"gzip"`.
23+
* `algorithm`: Can be a `function(buf, callback)` or a string. For a string the algorithm is taken from `zlib` (or zopfli for `zopfli`). Defaults to `"gzip"`.
2424
* `regExp`: All assets matching this RegExp are processed. Defaults to every asset.
2525
* `threshold`: Only assets bigger than this size are processed. In bytes. Defaults to `0`.
2626
* `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`.
2727

28+
Option Arguments for Zopfli (see [node-zopfli](https://github.com/pierreinglebert/node-zopfli#options) doc for details):
29+
* verbose: Default: false,
30+
* verbose_more: Default: false,
31+
* numiterations: Default: 15,
32+
* blocksplitting: Default: true,
33+
* blocksplittinglast: Default: false,
34+
* blocksplittingmax: Default: 15
35+
2836
## License
2937

3038
MIT (http://www.opensource.org/licenses/mit-license.php)

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function CompressionPlugin(options) {
2020
}
2121
this.algorithm = function (content, fn) {
2222
zopfli.gzip(content, {
23-
verbose: true,
24-
verbose_more: false,
25-
numiterations: 15,
26-
blocksplitting: true,
27-
blocksplittinglast: false,
28-
blocksplittingmax: 15
23+
verbose: options.verbose ? options.verbose : false,
24+
verbose_more: options.verbose ? options.verbose : false,
25+
numiterations: options.verbose ? options.verbose : 15,
26+
blocksplitting: options.verbose ? options.verbose : true,
27+
blocksplittinglast: options.verbose ? options.verbose : false,
28+
blocksplittingmax: options.verbose ? options.verbose : 15
2929
}, fn);
3030
};
3131
} else {

0 commit comments

Comments
 (0)