-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
51 lines (43 loc) · 1.42 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 path from 'path'
import { spawn } from 'child_process'
import gulp from 'gulp'
import webpack from 'webpack'
import del from 'del'
import backendConfig from './webpack.config.backend'
import productionConfig from './webpack.config.production'
function onBuild() {}
gulp.task('clean-dev', () => del([backendConfig.output.path]))
gulp.task('clean-build', () => del([productionConfig.backend.output.path,
productionConfig.frontend.output.path]))
gulp.task('backend-watch', done => {
let fireDone = false
webpack(backendConfig).watch(null, (err, stats) => {
onBuild(err, stats)
if (!fireDone) {
fireDone = true
done()
}
})
})
gulp.task('server-start', () => {
const entry = path.join(__dirname, 'dev/backend')
const server = spawn('node', [entry])
server.stdout.on('data', data => process.stdout.write(data))
server.stderr.on('data', data => process.stderr.write(data))
// eslint-disable-next-line no-console
server.on('exit', code => console.log(`child process exited with code ${code}`))
})
gulp.task('backend-build', done => {
webpack(productionConfig.backend).run((err, stats) => {
onBuild(err, stats)
done()
})
})
gulp.task('frontend-build', done => {
webpack(productionConfig.frontend).run((err, stats) => {
onBuild(err, stats)
done()
})
})
gulp.task('dev', gulp.series('clean-dev', 'backend-watch', 'server-start'))
gulp.task('build', gulp.series('clean-build', 'backend-build', 'frontend-build'))