-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
51 lines (45 loc) · 1.14 KB
/
gulpfile.babel.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
import babel from 'gulp-babel';
import envFile from 'node-env-file';
import gulp from 'gulp';
import nodemon from 'gulp-nodemon';
import rimraf from 'rimraf';
import sourcemaps from 'gulp-sourcemaps';
const SOURCE = {
ALL: 'src/**/*.js',
DIST: 'dist',
};
gulp.task('default', ['build'], () => {
envFile('./env.dev.list');
return nodemon({
script: './dist/server/app.js',
watch: SOURCE.ALL,
tasks: ['build'],
env: { NODE_ENV: 'development' },
});
});
gulp.task('server', ['build'], () => {
envFile('./env.prod.list');
return nodemon({
script: './dist/server/app.js',
watch: SOURCE.ALL,
tasks: ['build'],
env: { NODE_ENV: 'production' },
});
});
gulp.task('updateSchema', ['build'], () => {
envFile('./env.dev.list');
return nodemon({
script: './dist/server/updateSchema.js',
watch: SOURCE.ALL,
tasks: ['build'],
env: { NODE_ENV: 'development' },
});
});
gulp.task('clean', () => rimraf.sync(SOURCE.DIST));
gulp.task('build', ['clean'], () => {
return gulp.src(SOURCE.ALL)
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});