-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (43 loc) · 1.34 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
const gulp = require('gulp')
const babel = require('gulp-babel')
const path = require('path')
const nodemon = require('gulp-nodemon')
const chalk = require('chalk')
gulp.task('build-scripts', () => {
return gulp.src(['scripts/**/*.ts', 'scripts/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('./build/scripts'))
})
gulp.task('build', gulp.series('build-scripts', () => {
return gulp.src(['src/**/*.ts', 'src/**/*.js'])
.pipe(babel())
// output files to dist for prod
.pipe(gulp.dest('./dist'))
// output files to build/src for scripts
.pipe(gulp.dest('./build/src'))
}))
gulp.task('watch', gulp.series('build', async (done) => {
// gulp.watch('./*.js', gulp.series('build'));
return nodemon({
script: './dist/index.js',
watch: ['src/**'],
ext: 'js ts',
tasks: files => {
// eslint-disable-next-line no-console
console.log(
chalk.yellow(
'',
files.map(f => path.relative(process.cwd(), f)).join('\n')
)
)
return ['build']
},
done: done,
delay: '100',
}).once('quit', function() {
// eslint-disable-next-line no-console
console.log(chalk.yellow('[nodemon] Quit.'))
done()
process.exit()
})
}));