-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (56 loc) · 1.97 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
var gulp = require('gulp');
var task = gulp.task;
var src = gulp.src, dest = gulp.dest;
var less = require('gulp-less');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var del = require('del');
var tsb = require('gulp-tsb');
function buildLess(isDist) {
var r = src('./src/static/less/*.less')
.pipe(less());
if (isDist) {
r = r.pipe(minifyCSS()); }
return r.pipe(gulp.dest('./static/css'));
}
var tsConfig = tsb.create('src/tsconfig.json');
function buildServerTS(isDist) {
var r = src([ 'typings/**/*.ts', 'src/**/*.ts' ])
.pipe(tsConfig())
.pipe(gulp.dest('src'));
return r;
}
var tsConfigTest = tsb.create('test/tsconfig.json');
function buildTestTS(isDist) {
var r = src([ 'typings/**/*.ts', 'test/**/*.ts' ])
.pipe(tsConfigTest())
.pipe(gulp.dest('test'));
return r;
}
function buildJS(isDist) {
var r = src('./src/static/js/*.js')
if (isDist) {
r = r.pipe(uglify())
.pipe(rename({ 'suffix': '.min' }));
}
return r.pipe(gulp.dest('./static/js'));
}
gulp.task('clean', () =>
del([ 'static/css', 'static/js' ]));
gulp.task('build-css', buildLess.bind(null, false));
gulp.task('build-css:dist', buildLess.bind(null, true));
gulp.task('build-js', buildJS.bind(null, false));
gulp.task('build-js:dist', buildJS.bind(null, true));
gulp.task('build-ts-server', buildServerTS.bind(null, false));
gulp.task('build-ts-test', buildTestTS.bind(null, false));
gulp.task('build',
[ 'build-js', 'build-css', 'build-ts-server', 'build-ts-test' ]);
gulp.task('build-dist',
[ 'build-js:dist', 'build-css:dist', 'build-ts-server', 'build-ts-test' ]);
gulp.task('watch', function () {
gulp.watch('./src/static/less/*.less', [ 'build-css' ]);
gulp.watch('./src/static/js/*.js', [ 'build-js' ]);
gulp.watch('./src/**/*.ts', [ 'build-ts-server' ]);
});
gulp.task('default', [ 'build' ]);