-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpfile.js
89 lines (84 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
83
84
85
86
87
88
89
var gulp = require('gulp')
var plumber = require('gulp-plumber')
var less = require('gulp-less')
var autoprefixer = require('gulp-autoprefixer')
var concat = require('gulp-concat')
var uglify = require('gulp-uglify')
var minifycss = require('gulp-minify-css')
//var cssmin = require('gulp-cssmin')
var del = require('del')
gulp.task('zepto', function(){
// 控制并发时记得返回
return gulp.src([
// zeptojs/make :L42 @modules 'zepto event ajax form ie'
'bower_components/zeptojs/src/zepto.js',
'bower_components/zeptojs/src/event.js',
'bower_components/zeptojs/src/ajax.js',
'bower_components/zeptojs/src/form.js',
'bower_components/zeptojs/src/ie.js'
])
.pipe(plumber())
.pipe(concat('zepto.min.js'))
.pipe(uglify())
.pipe(gulp.dest('static/dist'))
})
gulp.task('misc', function () {
return gulp.src([
'static/lib/**',
//'bower_components/animate.css/animate.min.css',
//'bower_components/jquery/dist/jquery.min.js',
//'bower_components/jquery/dist/jquery.min.map',
//'bower_components/lodash/lodash.min.js',
'bower_components/jquery.serializeJSON/jquery.serializejson.min.js'
])
.pipe(plumber())
//.pipe(uglify())
.pipe(gulp.dest('static/dist'))
})
gulp.task('modern', ['misc'], function () {
return gulp.src([
'static/dist/modern/css/modern.css',
'static/dist/modern/css/modern-responsive.css'
])
.pipe(plumber())
.pipe(concat('modern.min.css'))
.pipe(minifycss())
.pipe(gulp.dest('static/dist/modern/css'))
})
gulp.task('external', ['zepto', 'misc', 'modern'])
gulp.task('less', function () {
return gulp.src([
'src/web/admin.less',
'src/web/common.less'
])
.pipe(plumber())
.pipe(less())
.pipe(autoprefixer({
browsers: 'Android 4, iOS 6, last 20 versions'
}))
.pipe(minifycss({
processImport: false // 不处理@import
}))
.pipe(gulp.dest('static/dist/app'))
})
gulp.task('js', function () {
return gulp.src([
'src/web/**/*.js'
])
.pipe(plumber())
.pipe(uglify())
.pipe(gulp.dest('static/dist/app'))
})
gulp.task('source', ['less', 'js'])
gulp.task('clean', function (cb) {
del([
'static/dist'
], cb)
})
gulp.task('build', ['external', 'source'])
gulp.task('watch', function () { // watch需要单独开
gulp.watch('src/web/**/*.less', ['less'])
gulp.watch('src/web/**/*.js', ['js'])
//gulp.watch('src/web/**/*.html', ['html'])
})
gulp.task('default', ['source'])