-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
80 lines (76 loc) · 1.68 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
var gulp = require("gulp")
var babel = require("gulp-babel")
var uglify = require("gulp-uglify")
var minify = require("gulp-minify-css")
var imagemin = require("gulp-imagemin")
var htmlmin = require("gulp-htmlmin")
var concat = require('gulp-concat')
/**
* 转码与压缩
*/
gulp.task("conversion", function (callback) {
gulp.src("js/base/**/*.js")
.pipe(babel({
presets: ["es2015"]
}))
.pipe(concat("base.js"))
.pipe(uglify())
.pipe(gulp.dest('src/js/base/'))
})
gulp.task("conversionPage", function () {
gulp.src("js/page/**/*.js")
.pipe(babel({
presets: ["es2015"]
}))
.pipe(gulp.dest("src/js/page/"))
.pipe(uglify())
.pipe(gulp.dest("src/js/page/"))
})
/**
* 压缩css
*/
gulp.task("compressionJsPlug", function () {
gulp.src("js/plug/**/*.js")
.pipe(uglify())
.pipe(gulp.dest("src/js/plug/"))
})
/**
* 压缩图片
*/
gulp.task("compressionImg", function () {
gulp.src("img/*")
.pipe(imagemin())
.pipe(gulp.dest("src/img"))
})
/**
* 压缩html
*/
gulp.task("compressionHtml", function () {
gulp.src("page/*.html")
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest("src/page/"))
gulp.src("index.html")
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest("src/"))
})
/**
* 复制文件夹
*/
gulp.task("copyTask", function () {
gulp.src("fonts/**/*")
.pipe(gulp.dest("src/fonts/"))
})
/**
* 压缩css
*/
gulp.task("compressionCss", function () {
gulp.src("css/**/*.css")
.pipe(minify())
.pipe(gulp.dest("src/css/"))
})
gulp.task("start", ["conversion", "conversionPage",
"compressionJsPlug",
"compressionImg",
"compressionHtml",
"copyTask",
"compressionCss"])