2015-09-25 16:08:54 -06:00
|
|
|
'use strict';
|
|
|
|
|
2015-09-25 17:55:33 -06:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var gzip = require('gulp-gzip');
|
|
|
|
var config = require('../config');
|
|
|
|
var filter = require('gulp-filter');
|
|
|
|
var replace = require('gulp-replace');
|
2015-09-25 16:08:54 -06:00
|
|
|
|
|
|
|
gulp.task('gzip', function() {
|
2015-09-25 17:55:33 -06:00
|
|
|
var rewriteFilter = filter(config.gzip.rewrite, { restore: true });
|
2015-09-25 16:08:54 -06:00
|
|
|
|
|
|
|
return gulp.src(config.gzip.src)
|
2015-09-25 17:55:33 -06:00
|
|
|
.pipe(rewriteFilter)
|
|
|
|
.pipe(replace(/"((?:css|js)\/.*\.(?:css|js))"/g, '"$1.gz"'))
|
|
|
|
.pipe(rewriteFilter.restore)
|
2015-09-25 16:08:54 -06:00
|
|
|
.pipe(gzip(config.gzip.options))
|
|
|
|
.pipe(gulp.dest(config.gzip.dest));
|
|
|
|
|
|
|
|
});
|