This repository has been archived by the owner on Sep 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
103 lines (95 loc) · 2.32 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
var gulp = require('gulp');
var pkg = require('./package.json');
var concat = require('gulp-concat');
var minify = require('gulp-minify');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var less = require('gulp-less');
var del = require('del');
var path = require('path');
var spawn = require('child_process').spawn;
var compilelist =
[
{
"name": "main_js",
"type": "js",
"src": "./src/js/main/*.js",
"outfile":"main.js",
"dest":"./build/js/"
},
{
"name": "main_less",
"type": "less",
"src": "./src/less/main/*.less",
"outfile":"main.css",
"dest":"./build/css/"
},
{
"name": "polyfill_js",
"type": "js",
"src": "./src/js/polyfill/*.js",
"outfile":"polyfill.js",
"dest":"./build/js/"
}
];
var copylist =
[
];
gulp.task('compile', function(){
for(var i = 0; i < compilelist.length; i++)
{
var t = compilelist[i];
process.stdout.write(t.name);
process.stdout.write("\n");
if(t.type=="js")
{
gulp.src(t.src)
.pipe(concat(t.outfile))
.pipe(gulp.dest(t.dest))
.pipe(uglify())
.pipe(rename({ extname: '.min.js'}))
.pipe(gulp.dest(t.dest));
}
else if(t.type=="css")
{
gulp.src(t.src)
.pipe(concat(t.outfile))
.pipe(gulp.dest(t.dest));
}
else if(t.type=="less")
{
gulp.src(t.src)
.pipe(less())
.pipe(concat(t.outfile))
.pipe(gulp.dest(t.dest));
}
}
});
gulp.task('copy', function(){
for(var i = 0; i < copylist.length; i++)
{
var t = copylist[i];
gulp.src(t.src).pipe(gulp.dest(t.dest));
}
});
gulp.task('clean', function () {
return del([
'./build/js/**/*',
'./build/css/**/*'
]);
});
gulp.task('test', function(){
var scripts =
[
"./src/js/main/*.js",
"./src/js/polyfill/*.js"
];
for(var i = 0; i < scripts.length; i++)
{
gulp.src(scripts[i])
.pipe(jshint())
.pipe(jshint.reporter('default'));
}
});
gulp.task('default', ['clean', 'copy','compile']);