a Zopfli plugin for gulp, based on node-zopfli.
npm install --save-dev gulp-zopfli
You can pass an options array to the zopfli object. These options are
passed on to node-zopfli
library, except for one: the format
options is
used to pick a compression format. The possible formats are: "deflate"
, "zlib"
or "gzip"
.
The defaults options are:
{
format: "gzip",
verbose: false,
verbose_more: false,
numiterations: 15,
blocksplitting: true,
blocksplittinglast: false,
blocksplittingmax: 15
};
var gulp = require("gulp");
var zopfli = require("gulp-zopfli");
gulp.task("compress", function() {
gulp.src("./dev/scripts/*.js")
.pipe(zopfli())
.pipe(gulp.dest("./public/scripts"));
});
gulp.task("default", function() {
gulp.run("compress");
});
Since the plugin is based largely on it,
if you're already using gulp-gzip,
switching to zopfli
should be as easy as replacing
var gzip = require("gulp-gzip");
by
var gzip = require("gulp-zopfli");
This plugin was based largely on gulp-gzip,
I basically just replaced gzip
by zopfli
so all credit is due to Jeremy.