stackviz/gulp/tasks/gzip.js
Tim Buckley 6ae7d8ace1 Use gulp-replace to rewrite JS and CSS paths during gzip task.
`index.html.gz` now links properly to gzipped resources allowing
them to be distributed unmodified and without the uncompressed
resources.

Change-Id: I253f5207de5b13a105dfb8ddd226d7da6ba2b34b
2015-09-25 17:55:33 -06:00

20 lines
538 B
JavaScript

'use strict';
var gulp = require('gulp');
var gzip = require('gulp-gzip');
var config = require('../config');
var filter = require('gulp-filter');
var replace = require('gulp-replace');
gulp.task('gzip', function() {
var rewriteFilter = filter(config.gzip.rewrite, { restore: true });
return gulp.src(config.gzip.src)
.pipe(rewriteFilter)
.pipe(replace(/"((?:css|js)\/.*\.(?:css|js))"/g, '"$1.gz"'))
.pipe(rewriteFilter.restore)
.pipe(gzip(config.gzip.options))
.pipe(gulp.dest(config.gzip.dest));
});