This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
forked from ZJUEVA/ReEVA-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (49 loc) · 1.42 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
50
51
52
53
54
55
56
57
58
const gulp = require('gulp');
const nodemon = require('gulp-nodemon')
const ts = require('gulp-typescript');
const tsp = ts.createProject('tsconfig.json'); //使用tsconfig.json文件配置tsc
const exec = require('child_process').exec
const clean = require('gulp-rimraf');
//目录常量
const PATHS = {
scripts: ['src/**/**.ts'],
output: './build',
};
gulp.task('clean/client', function () {
return gulp.src('./client/build').pipe(clean())
})
gulp.task('sw', function () {
exec('sw-precache-cra --no-minify --config sw-config.js', { cwd: './client' })
})
gulp.task('test/server', function () {
exec('jest --colors', (err, stdout, stderr) => {
console.log(stdout)
console.log(stderr)
})
})
//编译ts文件
gulp.task('build/server', function () {
return gulp.src(PATHS.scripts, { ignore: "*.spec.ts" })
.pipe(tsp())
.pipe(gulp.dest(PATHS.output))
})
//监视ts文件变化
gulp.task('watch/server', function () {
gulp.watch(PATHS.scripts, ['build/server'])
})
//自动重启服务器
gulp.task('nodemon', function () {
return nodemon({
//nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec ts-node src/server/server.ts
script: 'src/server.ts',
exec: "ts-node",
ignore: "src/**/*.spec.ts",
ext: 'ts',
env: { 'NODE_ENV': 'development' }
})
})
//开发任务
gulp.task('dev/server', ['nodemon'])
gulp.task('dev', ['dev/server'])
gulp.task('build', ['build/server'])
gulp.task('test', ['test/server'])