-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
36 lines (29 loc) · 1.24 KB
/
Copy pathgulpfile.js
File metadata and controls
36 lines (29 loc) · 1.24 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
// From https://rdyar.github.io/2016/03/25/gulp-file-for-jekyll-browser-sync/
var gulp = require('gulp');
var browserSync = require('browser-sync');
var cp = require('child_process');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
/** * Build the Jekyll Site (windows) if you use Mac/Linux change jekyll.bat to just jekyll */
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
/** Rebuild Jekyll & do page reload when watched files change */
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/** Wait for jekyll-build, then launch the Server */
gulp.task('serve', ['jekyll-build'], function() {
browserSync.init({
server: "_site/"
});
});
/** Watch all files for changes, except the _site and other unneccessary folders */
gulp.task('watch', function () {
gulp.watch(['**/*.*', '!_site/**/*', '!node_modules/**/*','!.sass-cache/**/*' ], ['jekyll-rebuild']);
});
/**Default task, running just `gulp` will compile the jekyll site, launch BrowserSync & watch files. */
gulp.task('default', ['serve', 'watch']);