-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
42 lines (37 loc) · 1006 Bytes
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer-core');
var htmlMinifierOptions = {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeOptionalTags: true,
minifyJS: true,
minifyCSS: true
};
gulp.task('useref', function(){
var assets = $.useref.assets({
searchPath: 'public'
});
return gulp.src('public/**/*.html')
.pipe(assets)
.pipe($.if('*.css', $.postcss([
autoprefixer({
browsers: ['last 2 versions', 'Firefox ESR']
})
])))
.pipe($.if('*.css', $.minifyCss()))
.pipe($.if('*.js', $.uglify()))
.pipe($.rev())
.pipe(assets.restore())
.pipe($.useref())
.pipe($.revReplace({
prefix: '/2015/'
}))
.pipe($.if('*.html', $.htmlMinifier(htmlMinifierOptions)))
.pipe(gulp.dest('public'));
});
gulp.task('default', ['useref']);