forked from layui/layui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
105 lines (88 loc) · 2.77 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
90
91
92
93
94
95
96
97
98
99
/**
layui构建
*/
var pkg = require('./package.json');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var minify = require('gulp-minify-css');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var header = require('gulp-header');
var del = require('del');
var gulpif = require('gulp-if');
var minimist = require('minimist');
var argv = require('minimist')(process.argv.slice(2), {
default: {
ver: 'all'
}
});
var task = {
minjs: function() {
//可指定模块压缩
var mod = argv.mod ? function(){
return '(' + argv.mod.replace(/,/g, '|') + ')';
}() : '';
return gulp.src([
'./src/**/*'+ mod +'.js'
,'!./src/lay/all.js'
]).pipe(uglify())
.pipe(header('/** <%= pkg.name %>-v<%= pkg.version %> <%= pkg.description %> <%= pkg.license %> license By <%= pkg.homepage %> */\n ;', {pkg: pkg}))
.pipe(gulp.dest('./build'))
}
,alljs: function(){
return gulp.src([
,'./src/layui.js'
,'./src/lay/**/{all,laytpl,laypage,laydate,jquery,layer,element,upload,form,tree,util,flow,layedit,code}.js'
,'!./src/lay/**/layim.js' //LayIM需授权
,'!./src/lay/**/mobile/*.js'
]).pipe(uglify())
.pipe(concat('layui.all.js', {newLine: ''}))
.pipe(header('/** <%= pkg.name %>-v<%= pkg.version %> <%= pkg.description %> <%= pkg.license %> license By <%= pkg.homepage %> */\n ;', {pkg: pkg}))
.pipe(gulp.dest('./build/lay/dest/'));
}
,mincss: function() {
return gulp.src('./src/css/**/*.css')
.pipe(minify({
compatibility: 'ie7'
}))
.pipe(header('/** <%= pkg.name %>-v<%= pkg.version %> <%= pkg.description %>@<%= pkg.license %> <%= pkg.homepage %> By <%= pkg.author %> */\n', {pkg : pkg} ))
.pipe(gulp.dest('./build/css'));
}
,font: function() {
return gulp.src('./src/font/*')
.pipe(rename({}))
.pipe(gulp.dest('./build/font'));
}
,images: function(){
gulp.src([
'./src/css/**/*.png'
,'./src/css/**/*.jpg'
,'./src/css/**/*.gif'
]).pipe(rename({}))
.pipe(gulp.dest('./build/css'));
return gulp.src([
'./src/images/**/*.png'
,'./src/images/**/*.jpg'
,'./src/images/**/*.gif'
]).pipe(rename({}))
.pipe(gulp.dest('./build/images'));
}
};
//清理
gulp.task('clear', function(cb) {
return del(['./build/*'], cb);
});
gulp.task('minjs', task.minjs); //压缩js模块
gulp.task('alljs', task.alljs); //打包模块完整版
gulp.task('mincss', task.mincss); //压缩css文件
gulp.task('font', task.font); //复制iconfont文件
gulp.task('images', task.images); //复制组件可能所需的图片
//完整任务
gulp.task('default', ['clear'], function(){
for(var key in task){
task[key]();
}
});
//开源版
gulp.task('open', ['clear'], function(){
});