-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
78 lines (63 loc) · 1.81 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const { series, src, dest, watch } = require('gulp');
const babel = require("gulp-babel");
const browserSync = require('browser-sync').create();
const plumber = require('gulp-plumber');
function serve() {
console.log('running serve');
browserSync.init({
server: ""
});
// watch("src/**/*.*", series(libs, copyHtml, js, css, other)).on('change', browserSync.reload);
// Do not copy the service worker file during dev.
watch("src/**/*.*", series(libs, copyHtml, js, css)).on('change', browserSync.reload);
}
// copy libs
function libs(){
console.log('running libs tasks');
return src('src/libs/*.*')
.pipe(dest('libs'))
};
// copy html files
function copyHtml() {
console.log('running html tasks');
return src([
'src/**/*.html',
])
.pipe(dest(__dirname));
};
// transpile to es5, copy to dist folder
function js() {
console.log('running js tasks');
return src('src/js/**/*.js')
.pipe(plumber(function(err) {
console.error('err with scripts', err);
this.emit('end');
}))
.pipe(babel())
.pipe(dest('js'));
};
// css files
function css() {
console.log('running css tasks');
return src('src/css/**/*.css')
.pipe(plumber(function(err) {
console.error('err with styles', err);
this.emit('end');
}))
.pipe(dest('css'));
};
// copy service worker file
function other(){
console.log('running other tasks');
return src([
'src/sw.js'
])
.pipe(plumber(function(err) {
console.error('err with other scripts', err);
this.emit('end');
}))
.pipe(babel())
.pipe(dest(__dirname))
};
exports.serve = serve;
exports.default = series(libs, copyHtml, js, css, other);