jstuckey / gulp-gzip

Gzip plugin for gulp.
MIT License
175 stars 17 forks source link

Threshold option does nothing #12

Closed okiii closed 9 years ago

okiii commented 9 years ago

I'm not 100% sure if I'm using the 'threshold' option correctly, but I can't seam to get it to work no matter what I pass to it.

Here's my task:

gulp.task('zip-html', ['html'], function() {
    gulp.src(['../../public/**/*.html', '../../public/**/*.xml'])
        .pipe(gzip({
            gzipOptions: {
                threshold: 152,
                level: 9
            }
        }))
        .pipe(gulp.dest('../../public'))
});

I have a couple of very small files ~50 bytes that I don't want compressed since they end up larger than pre-compression. I've tried passing everything:

threshold: 152
threshold: '1kb'
threshold: true

But nothing seams to have any effect and the task compresses all src files.

jstuckey commented 9 years ago

Hey, @okiii. Sorry for the confusion.

threshold is separate from gzipOptions. threshold gets used by the gulp-gzip plugin itself, while gzipOptions are forwarded to the zlib module.

See if this works:

{
  threshold: 152,
  gzipOptions: {
    level: 9
  }
}
okiii commented 9 years ago

Awesome that worked great. Thank you @jstuckey :smiley:

Sorry for the noobish misunderstanding!

jstuckey commented 9 years ago

No worries! Glad to help.