-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (80 loc) · 2.09 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* @Description: Author Message
* @author huyangyang
* @date 2018/8/25
*/
var gulp = require('gulp'),
rev = require('gulp-rev'),
revC = require('gulp-rev-collector'),
cssMin = require('gulp-csso'),
uglify = require('gulp-uglify'),
clearAll = require('del'),
imagemin = require('gulp-imagemin');
gulp.task('default', gulp.series(clear, revCss, revJs, revFonts, revImg, revIcons, revHead, revBody, revAutoHtml, function (done) {
done()
}));
// paths
var cssSrc = ['./public/css/*.css', './public/css/*.css'],
jsSrc = ['./public/js/*.js', './public/js/app.js'],
headSrc = './views/partial/*.ejs',
bodySrc = './views/*.ejs',
autoHtmlSrc = './public/*',
imgSrc = './public/images/*',
iconsSrc = './public/icons/*',
fontsSrc = './public/fonts/*';
// revAutoHtml
function revAutoHtml() {
return gulp.src(autoHtmlSrc)
.pipe(gulp.dest('./dist'));
}
// css build
function revCss() {
return gulp.src(cssSrc)
.pipe(cssMin())
.pipe(rev())
.pipe(gulp.dest('./dist/css'))
.pipe(rev.manifest())
.pipe(gulp.dest('./dist/css'));
}
// js build
function revJs() {
return gulp.src(jsSrc)
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest('./dist/js'))
.pipe(rev.manifest())
.pipe(gulp.dest('./dist/js'));
}
// fonts
function revFonts() {
return gulp.src(fontsSrc)
.pipe(gulp.dest('./dist/fonts'));
}
// revImg
function revImg() {
return gulp.src(imgSrc)
.pipe(imagemin())
.pipe(gulp.dest('./dist/images'));
}
// revIcons
function revIcons() {
return gulp.src(iconsSrc)
.pipe(imagemin())
.pipe(gulp.dest('./dist/icons'));
}
// replace path
function revHead() {
return gulp.src(['dist/**/*.json', headSrc])
.pipe(revC({
replaceReved: true
}))
.pipe(gulp.dest('dist/views/partial'));
}
function revBody() {
return gulp.src(['dist/**/*.json', bodySrc])
.pipe(revC({replaceReved: true}))
.pipe(gulp.dest('dist/views'));
}
function clear() {
return clearAll('./dist/*');
}