-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
41 lines (33 loc) · 1007 Bytes
/
gulpfile.js
File metadata and controls
41 lines (33 loc) · 1007 Bytes
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
const { src, dest, series, parallel, watch } = require('gulp');
const browserSync = require('browser-sync').create();
const fsExtra = require('fs-extra');
function clean(done){
fsExtra.emptyDirSync('./publish');
done();
}
function copyStatic() {
return src('./src/**', { allowEmpty: true })
.pipe(dest('./publish'));
}
function watchActivities() {
watch('./src/**', { delay: 500 }, copyStatic);
}
function reloadServer(done) {
browserSync.reload();
done();
}
function browserSyncServer(){
// static server
browserSync.init({
server: {
baseDir: "./publish"
}
});
watch('./src/**', { delay: 500 }, series(copyStatic, reloadServer)); // this is to force a reload on the browser if any new static content is updated
}
const dev = series(clean, parallel(copyStatic), browserSyncServer);
const build = series(clean, parallel(copyStatic));
exports.build = build;
exports.watchActivities = watchActivities;
exports.dev = dev;
exports.default = watchActivities;