-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
51 lines (41 loc) · 1.34 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
const gulp = require('gulp')
const concat = require('gulp-concat')
const sourcemaps = require('gulp-sourcemaps')
const uglify = require('gulp-uglify')
const ngAnnotate = require('gulp-ng-annotate')
const liveServer = require('gulp-live-server')
const server = liveServer('app.js')
gulp.task('js', () => {
return gulp.src(['app/**/module.js', 'app/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('public/app.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('.'))
})
gulp.task('watch:frontend:js', () => {
return gulp.watch('app/**/*.js', gulp.series('js', () => {
server.notify({ path: 'public/app.js' })
}))
})
gulp.task('watch:frontend:static', () => {
return gulp.watch('public/**/*')
.on('change', (path) => {
server.notify({ path: path })
})
})
gulp.task('watch:server', () => {
return gulp.watch(['app.js', 'api/**/*.js', 'lib/**/*.js'])
.on('change', () => {
server.start.bind(server)()
})
})
gulp.task('watch:frontend', gulp.parallel('watch:frontend:js', 'watch:frontend:static'))
gulp.task('watch', gulp.parallel('watch:frontend', 'watch:server'))
gulp.task('server', () => {
// Start the server at the beginning of the task
return server.start()
})
gulp.task('build', gulp.parallel('js'))
gulp.task('default', gulp.parallel('js', 'watch', 'server'))