This repository has been archived by the owner on May 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
gulpfile.js
129 lines (111 loc) · 3.11 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var header = require('gulp-header');
var connect = require("gulp-connect");
var less = require("gulp-less");
var autoprefixer = require('gulp-autoprefixer');
var ejs = require("gulp-ejs");
var uglify = require('gulp-uglify');
var ext_replace = require('gulp-ext-replace');
var cssmin = require('gulp-cssmin');
var pkg = require("./package.json");
var banner =
"/** \n\
* jQuery WeUI V" + pkg.version + " \n\
* By 言川\n\
* http://lihongxun945.github.io/jquery-weui/\n \
*/\n";
gulp.task('js', function(cb) {
count = 0;
var end = function(){
count ++;
if(count >= 3) cb();
};
gulp.src([
'./src/js/city-data.js',
'./src/js/city-picker.js'
])
.pipe(concat({ path: 'city-picker.js'}))
.pipe(gulp.dest('./dist/js/'))
.on("end", end);
gulp.src([
'./src/js/swiper.jquery.js',
'./src/js/swiper-wrap.js',
'./src/js/photos.js'
])
.pipe(concat({ path: 'swiper.js'}))
.pipe(gulp.dest('./dist/js/'))
.on("end", end);
gulp.src([
'./src/js/jquery-extend.js',
'./src/js/template7.js',
'./src/js/hammer.js',
'./src/js/modal.js',
'./src/js/toast.js',
'./src/js/action.js',
'./src/js/pull-to-refresh.js',
'./src/js/infinite.js',
'./src/js/tab.js',
'./src/js/search-bar.js',
'./src/js/device.js',
'./src/js/picker.js',
'./src/js/select.js',
'./src/js/calendar.js',
'./src/js/datetime-picker.js',
'./src/js/popup.js',
'./src/js/notification.js',
'./src/js/toptip.js',
'./src/js/slider.js',
'./src/js/swipeout.js'
])
.pipe(concat({ path: 'jquery-weui.js'}))
.pipe(header(banner))
.pipe(gulp.dest('./dist/js/'))
.on("end", end);
});
gulp.task('uglify', ["js"], function() {
return gulp.src(['./dist/js/*.js', '!./dist/js/*.min.js'])
.pipe(uglify({
preserveComments: "license"
}))
.pipe(ext_replace('.min.js'))
.pipe(gulp.dest('./dist/js'));
});
gulp.task('less', function () {
return gulp.src(['./src/less/jquery-weui.less'])
.pipe(less())
.pipe(autoprefixer())
.pipe(header(banner))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('cssmin', ["less"], function () {
gulp.src(['./dist/css/*.css', '!./dist/css/*.min.css'])
.pipe(cssmin())
.pipe(header(banner))
.pipe(ext_replace('.min.css'))
.pipe(gulp.dest('./dist/css/'));
});
gulp.task('ejs', function () {
return gulp.src(["./demos/*.html", "!./demos/_*.html"])
.pipe(ejs({}))
.pipe(gulp.dest("./dist/demos/"));
});
gulp.task('copy', function() {
gulp.src(['./src/lib/**/*'])
.pipe(gulp.dest('./dist/lib/'));
gulp.src(['./demos/images/*.*'])
.pipe(gulp.dest('./dist/demos/images/'));
gulp.src(['./demos/css/*.css'])
.pipe(gulp.dest('./dist/demos/css/'));
});
gulp.task('watch', function () {
gulp.watch('src/js/**/*.js', ['js']);
gulp.watch('src/less/**/*.less', ['less']);
gulp.watch('demos/*.html', ['ejs']);
gulp.watch('demos/css/*.css', ['copy']);
});
gulp.task('server', function () {
connect.server();
});
gulp.task("default", ['watch', 'server']);
gulp.task("build", ['uglify', 'cssmin', 'copy', 'ejs']);