-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (37 loc) · 1.04 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
// grab our gulp packages
var gulp = require('gulp');
var del = require('del');
var typescript = require("gulp-typescript");
var typescriptProject = typescript.createProject("tsconfig.json");
var spawn = require('child_process').spawn;
var uglify = require('gulp-uglify');
var pump = require('pump');
var instance;
gulp.task('watch', ['cleanup', 'build', 'serve'], function () {
gulp.watch('src/**/*.ts', ['build', 'serve']);
});
gulp.task('cleanup', function () {
return del(['dist/*']);
});
gulp.task('build', ['cleanup'], function () {
return typescriptProject.src()
.pipe(typescriptProject())
.on('error', function () { console.log('typescript compiler crashed') })
.js
.pipe(gulp.dest("dist"));
});
gulp.task('serve', ['build'], function () {
if (instance) {
instance.kill();
}
return instance = spawn('node', ['dist/index.js'], { stdio: 'inherit' });
});
gulp.task('compress', ['cleanup', 'build'], function (cb) {
return pump([
gulp.src('dist/**/*.js'),
uglify(),
gulp.dest('dist')
],
cb
);
});