forked from dcloudio/mui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
167 lines (152 loc) · 4.22 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
'use strict';
var path = require('path');
var del = require('del');
var runSequence = require('run-sequence');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var pkg = require('./package.json');
// 路径配置信息
var config = {
path: {
less: [
'./less/mui.less',
],
fonts: './fonts/*',
js: [
'js/mui.js',
'js/mui.detect.js',
'js/mui.detect.5+.js',
'js/mui.event.js',
'js/mui.target.js',
'js/mui.fixed.js',
'js/mui.fixed.bind.js',
'js/mui.fixed.classlist.js',
'js/mui.fixed.animation.js',
'js/mui.fixed.fastclick.js',
'js/mui.fixed.keyboard.js',
'js/mui.namespace.js',
'js/mui.gestures.js',
'js/mui.gestures.flick.js',
'js/mui.gestures.swipe.js',
'js/mui.gestures.drag.js',
'js/mui.gestures.tap.js',
'js/mui.gestures.longtap.js',
'js/mui.gestures.hold.js',
'js/mui.gestures.pinch.js',
'js/mui.init.js',
'js/mui.init.5+.js',
'js/mui.back.js',
'js/mui.back.5+.js',
'js/mui.init.pullrefresh.js',
'js/mui.ajax.js',
'js/mui.ajax.5+.js',
'js/mui.layout.js',
'js/mui.animation.js',
'js/mui.class.js',
'js/mui.pullRefresh.js',
'js/mui.class.scroll.js',
'js/mui.class.scroll.pullrefresh.js',
'js/mui.class.scroll.slider.js',
'js/pullrefresh.5+.js',
'js/mui.offcanvas.js',
'js/actions.js',
'js/modals.js',
'js/popovers.js',
'js/segmented-controllers.js',
'js/switches.js',
'js/tableviews.js',
'js/mui.dialog.alert.js',
'js/mui.dialog.confirm.js',
'js/mui.dialog.prompt.js',
'js/mui.dialog.toast.js',
'js/mui.popup.js',
'js/input.plugin.js',
'js/mui.number.js'
]
},
dist: {
js: './dist/js',
css: './dist/css',
fonts: './dist/fonts'
},
uglify: {
compress: {
warnings: false
},
output: {
ascii_only: true
}
}
};
var dateFormat = 'isoDateTime';
var banner = [
'/*!',
' * =====================================================',
' * Mui v<%= pkg.version %> (<%= pkg.homepage %>)',
' * Licensed under <%= pkg.license %> | ' + $.util.date(Date.now(), dateFormat),
' * =====================================================',
' */\n'
].join('\n');
// clean
gulp.task('build:clean', function() {
return del([
config.dist.css,
config.dist.js
]);
});
// build less
gulp.task('build:less', function() {
gulp.src(config.path.less)
.pipe($.header(banner, {pkg: pkg, ver: ''}))
.pipe($.plumber({errorHandler: function(err) {
console.log(err);
this.emit('end');
}}))
.pipe($.less({
paths: [ path.join(__dirname, 'less') ]
}))
.pipe($.csscomb({configPath: path.join(__dirname, ".csscomb.json")}))
.pipe(gulp.dest(config.dist.css))
.pipe($.size({showFiles: true, title: 'source'}))
.pipe($.minifyCss({noAdvanced: true}))
.pipe($.rename({
suffix: '.min',
extname: '.css'
}))
.pipe(gulp.dest(config.dist.css))
.pipe($.size({showFiles: true, title: 'minified'}))
.pipe($.size({showFiles: true, gzip: true, title: 'gzipped'}));
});
// build fonts
gulp.task('build:fonts', function() {
gulp.src(config.path.fonts)
.pipe(gulp.dest(config.dist.fonts));
});
// build js
gulp.task('build:js', function() {
gulp.src(config.path.js)
.pipe($.concat('mui.js'))
.pipe($.header(banner, {pkg: pkg, ver: ''}))
.pipe(gulp.dest(config.dist.js))
.pipe($.size({showFiles: true, title: 'source'}))
.pipe($.uglify(config.uglify))
.pipe($.header(banner, {pkg: pkg, ver: ''}))
.pipe($.rename({suffix: '.min'}))
.pipe(gulp.dest(config.dist.js))
.pipe($.size({showFiles: true, title: 'minified'}))
.pipe($.size({showFiles: true, gzip: true, title: 'gzipped'}));
});
// build
gulp.task('build', function(cb) {
runSequence(
'build:clean',
['build:less', 'build:fonts', 'build:js'],
cb);
});
// watch
gulp.task('watch', function() {
gulp.watch(['js/*.js'], ['build:js']);
gulp.watch(['less/**/*.less'], ['build:less']);
});
// default
gulp.task('default', ['build']);