-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (44 loc) · 1.44 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
47
48
49
'use strict';
const gulp = require('gulp');
const ts = require('gulp-typescript');
const chalk = require('chalk');
const nodemon = require('gulp-nodemon');
const path = require('path');
// Constants
const rootDir = __dirname;
const SHARED_TS_CONFIG_PATH = path.resolve(__dirname, 'src/shared/tsconfig.json');
const SERVER_TS_CONFIG_PATH = path.resolve(__dirname, 'src/server/tsconfig.json');
const tsProject = ts.createProject(SERVER_TS_CONFIG_PATH);
const sharedTsProject = ts.createProject(SHARED_TS_CONFIG_PATH);
gulp.task('transpile-shared', () => {
return gulp.src(['./src/shared/**/*.ts', './src/shared/*.ts'])
.pipe(sharedTsProject())
.js
.pipe(gulp.dest('./dist/shared'));
});
gulp.task('transpile-server', ['transpile-shared'], () => {
console.log(chalk.yellow('Recompiling server-side typescript...'));
return gulp.src(['./src/server/**/*.ts', './src/server/*.ts'])
.pipe(tsProject())
.js
.pipe(gulp.dest('./dist/server'));
});
gulp.task('nodemon', ['transpile-server'], cb => {
let started = false;
return nodemon({
script: './dist/server',
ext: 'ts',
watch: './src/server',
tasks: ['transpile-server'],
env: { 'NODE_PATH': './' },
ignore: ['node_modules', 'package.json', 'gulpfile.js']
}).on('start', function() {
if (!started) {
cb();
started = true;
}
}).on('restart', function() {
console.log(chalk.green('Restarting server'));
});
});
gulp.task('default', ['nodemon']);