-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
64 lines (50 loc) · 1.45 KB
/
gulpfile.babel.js
File metadata and controls
64 lines (50 loc) · 1.45 KB
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
63
64
'use strict';
import gulp from 'gulp';
import del from 'del';
import babel from 'gulp-babel';
import concat from 'gulp-concat';
import replace from 'gulp-replace';
import sourcemaps from 'gulp-sourcemaps';
// CLEAN
gulp.task('clean-sw', () => {
return del('public/bin/*');
});
gulp.task('clean-modules', () => {
return del('public/modules/*');
});
gulp.task('clean-server', () => {
return del('bin/*');
});
// BUILD
gulp.task('build-sw', ['clean-sw'], () => {
return gulp.src('public/src/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015-native-generators'],
babelrc: false
}))
.pipe(concat('service-worker.js'))
.pipe(replace('<% VERSION %>', new Date().toISOString()))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/bin'));
});
gulp.task('build-server', ['clean-server'], () => {
return gulp.src('src/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015-native-generators'],
plugins: ['add-module-exports'],
babelrc: false
}))
.pipe(sourcemaps.write('.', {sourceRoot: '../src'}))
.pipe(gulp.dest('bin'));
});
gulp.task('build', ['build-sw', 'build-server'], () => {})
// WATCH
gulp.task('watch-sw', ['build-sw'], () => {
return gulp.watch('public/src/*.js', ['build-sw']);
});
gulp.task('watch-server', ['build-server'], () => {
return gulp.watch('src/*.js', ['build-server']);
});
gulp.task('watch', ['watch-sw', 'watch-server'], () => {});