-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (39 loc) · 933 Bytes
/
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
const gulp = require('gulp4');
const ts = require('gulp-typescript');
const notifier = require('node-notifier');
const devServer = require('gulp-develop-server');
const tsProject = ts.createProject('tsconfig.json');
const notify = (msg, opt) => {
notifier.notify({
title: '',
message: msg || '',
sound: true,
wait: false,
timeout: 2
});
console.log(msg);
};
gulp.task('compileTs', () => {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest('dist'))
.on('end', () => {
notify('Compile successfully.');
});
});
gulp.task('serve', done => {
devServer.listen({ path: './dist/samples/index.js' });
done();
});
gulp.task('watch', done => {
gulp.watch([
'./index.ts',
'./lib/**/*.ts',
'./samples/**/*.ts'
], gulp.series('compileTs', devServer.restart));
done();
});
gulp.task('default', gulp.series(
'compileTs',
gulp.parallel('serve', 'watch')
));