-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (67 loc) · 2.43 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
81
82
const gulp = require('gulp');
const rename = require('gulp-rename');
const htmlmin = require('gulp-htmlmin');
const concat = require('gulp-concat');
// const sprite = require('gulp.spritesmith');
const imagemin = require('gulp-imagemin');
const cssmin = require('gulp-cssmin');
const less = require('gulp-less');
const jsmin = require('gulp-uglify');
const path = require('path');
// const merge = require('merge-stream');
const copy = require('gulp-copy');
const util = require('gulp-util');//打印错误信息
// const buffer = require('vinyl-buffer');
gulp.task('htmlmin', function() {
return gulp.src('./src/html/public/*.html')
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('./dist/html/public'));
});
gulp.task('cssmin',function(){
return gulp.src('./src/css/*.css')
.pipe(cssmin())
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest('./dist/css'));
})
gulp.task('jsmin',function(){
return gulp.src('./src/js/*.js')
.pipe(jsmin())
.on('error', function(err) {
util.log(util.colors.red('[Error]'), err.toString());
})
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest('./dist/js'));
})
// gulp.task('sprite', function() {
// var spriteData = gulp.src('./src/img/icon/*')
// .pipe(sprite({
// imgName: 'sprite.png',
// cssName: 'sprite.css'
// }));
// var imgStream = spriteData.img.pipe(buffer()).pipe(gulp.dest('./src/img/'));
// var cssStream = spriteData.css.pipe(gulp.dest('./src/css/library'));
// return merge(imgStream, cssStream);
// });
gulp.task('imagemin', function() {
return gulp.src('./src/image/*')
.pipe(imagemin())
.pipe(gulp.dest('./dist/img'));
});
gulp.task('less', function() {
return gulp.src('./src/style/*.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
}))
.pipe(gulp.dest('./src/css'));
});
gulp.task('copy', function() {
return gulp.src(['./src/style/**/*','!src/style/*.less'])
.pipe(gulp.dest('./src/css/'))
.pipe(gulp.dest('./dist/css/'));;
});
// gulp.task('watchless', function() {
// gulp.watch('./src/styles/*.less', gulp.series('less'));
// });
// gulp.task('dev', function() {
// gulp.watch(['./src/styles/*.less', './src/html/*.html', './src/js/*.js'], gulp.series('htmlmin', 'concatjs', 'less', 'cssmin', 'jsmin'));
// });