Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 725 Bytes

File metadata and controls

27 lines (20 loc) · 725 Bytes

GZip dist gulp task

Servers are able to gzip files on the fly, but most of them can also serve "pre-gziped" files and thus avoid any CPU usage in runtime associated with the task. For instance, you can configure nginx to do so.

This recipe makes gzipped versions of all files in dist folder

  1. Install gulp-gzip
    npm install gulp-gzip --save-dev

  2. Add the following code to your Gulpfile:

var gzip = require('gulp-gzip');

gulp.task('gzip', ['index'], function(cb) {
  gulp.src('./dist/**')
    .pipe(gzip({
      append: true,
      level: 9
    }))
    .pipe(gulp.dest('dist'))
    .on('end', cb);
  });
  1. Run the new task
    gulp gzip