-
Notifications
You must be signed in to change notification settings - Fork 34
/
gulpfile.js
62 lines (52 loc) · 1.36 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
59
60
61
62
const gulp = require('gulp')
const babel = require('gulp-babel')
const watch = require('gulp-watch')
const del = require('del')
const dotenv = require('dotenv')
dotenv.config()
const ASSETS = './src/nodeuii/**/*.js'
const DIST_PATH = './dist'
gulp.task('clean', () => {
return del(DIST_PATH, {
force: true
})
})
gulp.task('copyEnv', () => {
return gulp.src('.env')
.pipe(gulp.dest('./dist'))
})
gulp.task('copyDotenv', () => {
return gulp.src('./dotenv.js')
.pipe(gulp.dest('./dist'))
})
gulp.task('copyEnvs', () => {
return gulp.src(`./profiles/${process.env.NODE_ENV}/**/*.env`)
.pipe(gulp.dest(`./dist/profiles/${process.env.NODE_ENV}`))
})
gulp.task('build:dev', () => {
return watch(ASSETS, { ignoreInitial: false }, () => {
gulp.src(ASSETS)
.pipe(babel({
babelrc: false,
'plugins': [
'transform-es2015-modules-commonjs'
]
}))
.pipe(gulp.dest('./dist'))
})
})
gulp.task('build:prod', () => {
return gulp.src(ASSETS)
.pipe(babel({
babelrc: false,
'plugins': [
'transform-es2015-modules-commonjs'
]
}))
.pipe(gulp.dest('./dist'))
})
let _task = gulp.series('clean', 'copyEnv', 'copyDotenv', 'copyEnvs', 'build:dev')
if (process.env.NODE_ENV === 'production') {
_task = gulp.series('clean', 'copyEnv', 'copyDotenv', 'copyEnvs', 'build:prod')
}
gulp.task('default', _task)