-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
48 lines (44 loc) · 1.32 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
// 载入外挂
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'), //压缩CSS
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
autoprefixer = require('gulp-autoprefixer');
// 压缩非minjs,检查JS
gulp.task('scripts', function() {
return gulp.src(['src/js/*.js', '!js/*min.js'])// 要压缩的js文件
.pipe(uglify()) //使用uglify进行压缩,更多配置请参考:
.pipe(gulp.dest('dist/js'))//压缩后的路径
.pipe(notify({
message: 'Scripts task complete'
}));
});
// 压缩非mincss
gulp.task('styles', function() {
return gulp.src(['src/css/*.css', '!**/*min.css'])
.pipe(autoprefixer())
.pipe(minifycss())
.pipe(gulp.dest('dist/css'))
.pipe(notify({
message: 'styles task complete'
}));
});
/**
* 删除所有编译文件
*/
gulp.task('clean', function() {
return gulp.src(['build'], {
read: false
})
.pipe(clean());
});
// 预设任务
gulp.task('default', ['clean'], function() {
gulp.start(['scripts', 'styles']);
});