-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
44 lines (35 loc) · 1.05 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
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const child = require('child_process');
const tsProject = ts.createProject('tsconfig.json');
let node = null;
gulp.task('build', function () {
return tsProject.src()
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(tsProject())
.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
});
gulp.task('start', gulp.series('build', function(done) {
if (!!node) {
node.kill();
}
node = child.spawn('node', ['build/server.js'], {stdio: 'inherit'});
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
done();
}));
gulp.task('watch', gulp.series('build', 'start', function() {
gulp.watch(tsProject.config.include, gulp.series('build', 'start'));
}));
gulp.task('default', gulp.parallel('watch', 'start'));
process.on('exit', function() {
if (!!node) {
node.kill();
}
});