-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
65 lines (57 loc) · 1.5 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
var gulp = require('gulp');
var tsc = require('gulp-tsc');
var seq = require('run-sequence');
var del = require('gulp-clean');
var gls = require('gulp-live-server');
var chalk = require('chalk');
var gutil = require('gulp-util');
var tslint = require('gulp-tslint');
var paths = {
ts: {
src: [
'app/**/*.ts'
],
dest: 'build'
}
}
gulp.task('serve', () => {
seq('clean', 'build', 'watch');
})
gulp.task('watch', () => {
var server = gls('build/www.js', {env: {NODE_ENV: 'development'}}, 12345);
server.start();
gulp.watch(['app/**/*.ts'], () => seq('tslint', 'clean', 'build'));
gulp.watch(['build/**/*.js', 'build/**/*.css', 'build/**/*.html'], file =>
server.notify.apply(server, [file])
);
gulp.watch('build/www.js', () => {
setTimeout(() => gutil.log('Restart Succeed!'), 500);
server.start.bind(server)()
});
});
gulp.task('build', () => {
return gulp.src(paths.ts.src)
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tsc({
module: "CommonJS",
sourcemap: true,
emitError: false
}))
.pipe(gulp.dest(paths.ts.dest));
});
gulp.task('clean', () => {
del(paths.ts.dest);
});
gulp.task('rebuild', file => {
seq('clean', 'build');
});
gulp.task("tslint", () => {
return gulp.src(paths.ts.src)
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report());
});
gulp.task('default', ['rebuild']);