-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
46 lines (38 loc) · 1.07 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var cssminify = require('gulp-minify-css');
var htmlminify = require('gulp-htmlmin');
gulp.task('jsminify', function() {
gulp.src('./src/scripts/*.js')
.pipe(uglify())
.pipe(gulp.dest('./dist/scripts'));
});
gulp.task('cssminify', function() {
gulp.src('./src/styles/*.css')
.pipe(cssminify())
.pipe(gulp.dest('./dist/styles'));
});
gulp.task('htmlminify', function() {
gulp.src('./src/*.html')
.pipe(htmlminify({
removeComments: true,
collapseWhitespace: true
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('manifest', function(){
gulp.src('./src/manifest.json')
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', function(){
gulp.watch('./src/*.html', ['htmlminify']);
gulp.watch('./src/styles/*.css', ['cssminify']);
gulp.watch('./src/scripts/*.js', ['jsminify']);
});
// gulp.task('default', function() {
// gulp.run('jsminify', 'cssminify', 'htmlminify', 'manifest');
// });
// 发布
gulp.task('pub',['jsminify', 'cssminify', 'htmlminify', 'manifest']);
// 开发
gulp.task('dev',['watch']);