-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
70 lines (60 loc) · 1.3 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
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const cssnano = require('gulp-cssnano');
const htmlClean = require('gulp-htmlclean');
const imageMin = require('gulp-imagemin');
const del = require('del');
function minifyJS() {
return gulp
.src('dist/**/*.js')
.pipe(
uglify({
output: {
comments: false
}
})
)
.pipe(gulp.dest('./build'));
}
function minifyCSS() {
return gulp
.src('dist/**/*.wxss')
.pipe(cssnano())
.pipe(gulp.dest('./build'));
}
function minifyHTML() {
return gulp
.src('dist/**/*.wxml')
.pipe(htmlClean())
.pipe(gulp.dest('./build'));
}
function minifyImg() {
return gulp
.src(['dist/**/*.png', 'dist/**/*.jpg'])
.pipe(imageMin())
.pipe(gulp.dest('./build/'));
}
function copyOther() {
return gulp
.src(['dist/**/*.map', 'dist/**/*.json', 'dist/**/*.wxs'])
.pipe(gulp.dest('./build'));
}
function cleanBuild() {
return del(['build/**/*']);
}
function cleanDist() {
return del(['dist/**/*']);
}
function carry() {
return gulp.src('build/**/*').pipe(gulp.dest('dist'));
}
gulp.task(
'build',
gulp.series(
cleanBuild,
gulp.parallel(minifyJS, minifyCSS, minifyHTML, minifyImg, copyOther),
cleanDist,
carry
)
);
gulp.task('default', gulp.series('build'));