-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
71 lines (63 loc) · 2 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
var gulp = require('gulp'),
del = require('del'),
minifycss = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
jshint = require('gulp-jshint'),
runSequence = require('run-sequence'),
replace = require('gulp-replace'),
rev = require("gulp-rev"),
revColletor = require('gulp-rev-collector'),
htmlmin = require('gulp-htmlmin');
//check expression
gulp.task('jshint', function() {
return gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('copy', function() {
return gulp.src(['lib/**/*','fonts/**/*','img/**/*','js/**/*','inc/**/*.php','*.php'],{ base: '.' })
.pipe(gulp.dest('dist'))
});
gulp.task('buildCSS', function() {
return gulp.src('css/*.css')
.pipe(minifycss())
.pipe(rev())
.pipe(gulp.dest('dist/css'))
.pipe(rev.manifest())
.pipe(gulp.dest('.'));
});
gulp.task('revReplace',function () {
return gulp.src(['rev-manifest.json','dist/**/*.php'],{base:'dist'})
.pipe(revColletor({
replaceReved:true
}))
.pipe(gulp.dest('dist'));
})
gulp.task('htmlminify',function () {
return gulp.src(['index.php','page.php', 'post.php', 'template-links.php'])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
}))
.pipe(gulp.dest('dist'));
})
gulp.task('htmlminify-inc',function () {
return gulp.src(['inc/header.php', 'inc/footer.php', 'inc/sidebar.php'])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
ignoreCustomFragments: [/<main>/, /<\/main>/, /<\?[\s\S]*?(?:\?>|$)/]
}))
.pipe(gulp.dest('dist/inc'));
})
gulp.task('clean', function() {
return del('dist/*');
});
gulp.task('build', function() {
// build into a new folder
return runSequence(
'clean',
['copy','buildCSS','htmlminify', 'htmlminify-inc'],
'revReplace');
});