-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGulpfile.js
73 lines (61 loc) · 1.41 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
var exec = require('child_process').exec;
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var flatten = require('gulp-flatten');
gulp.task('browser-sync', function(cb) {
browserSync.init({
open: false,
port: 9000,
server: {
baseDir: './dist/',
},
});
cb();
});
gulp.task('build', function(cb, a, b) {
exec('yarn hackmyresume:build', function (err, stdout, stderr) {
if (err) {
console.error(`exec error: ${err}`);
return cb();
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
return cb();
});
});
gulp.task('watch-css', function(cb) {
// Avoid rebuilding everything for css changes !
gulp.watch([
'./src/**/*.css',
], {usePolling: true}, gulp.series([
(done) => {
gulp
.src('./src/**/html.css')
.pipe(flatten())
.pipe(gulp.dest('./dist/'))
.pipe(browserSync.stream())
;
done();
},
])
);
});
gulp.task('watch-tpl', function(cb) {
gulp.watch('src/**/*.{hbs,html,json}', {usePolling: true}, gulp.series([
(done) => {
console.log('Changes detected');
done();
},
'build',
(done) => {
browserSync.reload();
done();
},
])
);
});
gulp.task('default', gulp.series(gulp.parallel([
'browser-sync',
'watch-css',
'watch-tpl'
])));