-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
86 lines (71 loc) · 2.08 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
83
84
85
86
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var zip = require('gulp-zip');
const del = require('del');
var cheerhelper = require('./scripts/cheerhelper').CheerHelper;
gulp.task('sass', function() {
gulp.src('./dev/scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dev/css'));
cheerhelper.log('sass compile success');
});
gulp.task('sass:watch', function() {
gulp.watch('./dev/scss/*.scss', ['sass']);
});
// backup
gulp.task('backup', function() {
return gulp.src('./release/**')
.pipe(zip(new Date().format('yyyyMMdd_hhmmss') + '.zip'))
.pipe(gulp.dest('./backup'));
});
// clean
gulp.task('clean', ['backup'], function() {
cheerhelper.log('Starting clean...');
return del(['./release/**']).then(function(paths) {
cheerhelper.log('All files cleaned!');
});
})
// 新建发布目录
gulp.task('move', ['clean'], function() {
return gulp.src(['./dev/**', '!./dev/scss', '!./dev/scss/**']).pipe(gulp.dest('./release'));
});
// 编译sass&压缩css
gulp.task('sass-compress', ['move'], function() {
return gulp.src('./dev/scss/*.scss')
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(autoprefixer())
.pipe(gulp.dest('./release/css'));
});
// uglifyJs
gulp.task('uglifyJs', ['sass-compress'], function() {
return gulp.src(['./dev/js/**/*js'])
// .pipe(uglify({
// mangle: false,
// compress: {
// drop_console: true
// }
// }))
.pipe(gulp.dest('./release/js'));
});
// override
gulp.task('override', ['uglifyJs'], function(){
return gulp.src('./override/**').pipe(gulp.dest('./release'));
});
//**********************EXECUTABLE************************
gulp.task('dev', ['sass', 'sass:watch']);
gulp.task('release', ['override'], function() {
gulp.src('./release/**')
.pipe(zip('YJ_task_latest.zip'))
.pipe(gulp.dest('./release'));
});
gulp.task('bower', function() {
gulp.src('./bower_components/**').pipe(gulp.dest('./dev/lib'));
});