-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
51 lines (43 loc) · 1.09 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const server = require('gulp-develop-server');
const concat = require('gulp-concat');
const tsPath = './src/**/*.ts';
const jsPath = './dist/app.js';
gulp.task('default', function () {
console.log(' - build:server');
console.log(' - watch');
console.log(' - server:start');
console.log(' - server:restart');
console.log(' - server:watch');
});
gulp.task('build:server', () => {
const tsProject = ts.createProject('./src/tsconfig.json');
const tsResult = gulp.src(tsPath)
.pipe(ts(tsProject));
return tsResult.js
.pipe(gulp.dest('./dist'))
})
;
gulp.task('watch', () => {
gulp.watch(tsPath, ['build:server']);
})
;
gulp.task('server:start', () => {
server.listen({path: jsPath});
})
;
gulp.task('server:restart', () => {
server.restart((error) => {
if (error) {
console.error(error);
}
})
;
})
;
gulp.task('server:watch', ['server:start'], () => {
gulp.watch(tsPath, ['build:server']);
gulp.watch(jsPath, ['server:restart']);
})
;