-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·72 lines (64 loc) · 1.71 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var cssnano = require('cssnano');
var dirs = {
public: 'public',
screenshots: 'public/build/screenshots'
};
gulp.task('useref', ['screenshot'], function(){
var assets = $.useref.assets({
searchPath: 'public'
});
return gulp.src('public/**/*.html')
.pipe(assets)
.pipe($.uniqueFiles())
.pipe($.if('*.css', $.postcss([
cssnano()
])))
.pipe($.if('*.js', $.uglify()))
.pipe($.rev())
.pipe(assets.restore())
.pipe($.useref())
.pipe($.revReplace({
prefix: '/'
}))
.pipe(gulp.dest('public'));
});
gulp.task('screenshot:rev', function(){
return gulp.src('public/themes/screenshots/*.png')
.pipe($.rev())
.pipe(gulp.dest(dirs.screenshots))
.pipe($.rev.manifest())
.pipe(gulp.dest(dirs.screenshots));
});
gulp.task('screenshot:resize', ['screenshot:rev'], function(){
return gulp.src(dirs.screenshots + '/*.png')
.pipe($.responsive({
'*.png': [
{
width: 400,
progressive: true
},
{
progressive: true,
rename: {
suffix: '@2x'
}
}
]
}))
.pipe(gulp.dest(dirs.screenshots));
});
gulp.task('screenshot:revreplace', ['screenshot:rev'], function(){
return gulp.src([dirs.screenshots + '/rev-manifest.json', 'public/themes/index.html'])
.pipe($.revCollector({
replaceReved: true,
dirReplacements: {
'/themes/screenshots': '/build/screenshots'
}
}))
.pipe(gulp.dest('public/themes'));
});
gulp.task('screenshot', ['screenshot:rev', 'screenshot:resize', 'screenshot:revreplace']);
gulp.task('default', ['useref', 'screenshot']);