Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compression Level option (or hardcode to 9) #12

Closed
Parakleta opened this issue Sep 10, 2015 · 4 comments
Closed

Compression Level option (or hardcode to 9) #12

Parakleta opened this issue Sep 10, 2015 · 4 comments

Comments

@Parakleta
Copy link

Since ideally this should be part of a build chain that compresses once and then delivers many times (as opposed to live compression) it makes sense to use the highest possible compression level.

Can you please either add an option to specify, or else change the default to use level 9 instead of the zlib default of 6.

@bfin
Copy link

bfin commented Nov 30, 2015

Was looking to do the same thing. While I agree it'd be a useful option, @sokra has a lot on his plate. This is my workaround:

First, define your algorithm...

var zlib = require('zlib');
function gzipMaxCompression(buffer, callback) {
  return zlib['gzip'](buffer, {level: 9}, callback)
}

...then pass to CompressionPlugin

new CompressionPlugin({
    algorithm: gzipMaxCompression
})

@Parakleta
Copy link
Author

@bfin thanks very much, this workaround is exactly what I needed. I completely missed that you could pass in a function as the algorithm.

D1plo1d added a commit to D1plo1d/compression-webpack-plugin that referenced this issue Dec 9, 2015
@D1plo1d
Copy link

D1plo1d commented Dec 9, 2015

I've put in a pull request to add level as an option and set it by default to 9. Hopefully this can get merged in: #13

@sokra sokra closed this as completed in d4d96d2 Jan 23, 2016
@chaddjohnson
Copy link

chaddjohnson commented Nov 30, 2017

Please note that the algorithm callback now requires three arguments:

function gzipMaxCompression(buffer, options, callback) {
  return zlib['gzip'](buffer, {level: 9}, callback);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants