-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
45 lines (37 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const nodemon = require('gulp-nodemon');
const sourcemaps = require('gulp-sourcemaps');
const JSON_FILES = ['src/*.json', 'src/**/*.json'];
const path = require('path');
const fs = require('fs');
const appVersion = require('./package.json').version;
// pull in the project TypeScript config
const tsProject = ts.createProject('tsconfig.json');
gulp.task('version', function versionFile(done) {
const versionFilePath = path.join(__dirname + '/src/version.ts');
const src = `export const Version = '${appVersion}';\n`;
fs.writeFileSync(versionFilePath, src);
done();
});
gulp.task('scripts', function compile() {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
gulp.task('watch', gulp.series('scripts', async function watchTs() {
return gulp.watch('src/**/*.ts', gulp.series('scripts'));
}));
gulp.task('assets', function copyAssets() {
return gulp.src(JSON_FILES)
.pipe(gulp.dest('dist'));
});
gulp.task('nodemon', gulp.series(gulp.parallel('assets', 'watch'), async function runNodeMon() {
nodemon({
script: './dist/bin/start.js',
nodeArgs: ['--inspect']
});
}));
gulp.task('default', gulp.parallel('version', 'nodemon'));