-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (52 loc) · 1.62 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
var gulp = require('gulp')
var htmlmin = require('gulp-htmlmin');
var minifyCss = require('gulp-minify-css'); //- 压缩CSS为一行;
var uglify = require('gulp-uglify');
gulp.task('extend-output', function () {
gulp.src('./html/**/**/*.*')
.pipe(gulp.dest('./output'))
})
gulp.task('extend-pro', ['extend-output', 'minify', 'cssMin', 'copyOtherFiles'], function () {})
gulp.task('default', ['extend-pro'])
gulp.task('minify', function() {
console.log("minify");
return gulp.src('./output/**/**/*.html')
.pipe(htmlmin({
collapseBooleanAttributes:true,
collapseWhitespace:true,
decodeEntities:true,
html5:true,
// lint:true,
minifyCSS:true,
minifyJS:true,
processConditionalComments:true,
removeAttributeQuotes:true,
removeComments:true,
removeEmptyAttributes:true,
removeOptionalTags:true,
removeRedundantAttributes:true,
removeScriptTypeAttributes:true,
removeStyleLinkTypeAttributes:true,
removeTagWhitespace:true,
sortAttributes:true,
sortClassName:true,
useShortDoctype:true
}))
.pipe(gulp.dest('./production'))
});
gulp.task('cssMin', function() {
console.log('cssMin');
return gulp.src('./output/**/**/**/*.css')
.pipe(minifyCss())
.pipe(gulp.dest('./production'))
});
//copy other files
gulp.task("copyOtherFiles", function() {
console.log('copyOtherFiles');
gulp.src([
'./output/**/**/*.*',
'!' + './output/**/**/**/*.html',
'!' + './output/**/**/**/*.css'
])
.pipe(gulp.dest('./production'))
})