Created
July 5, 2015 02:29
-
-
Save pibby/2b8a21451dce40de05c6 to your computer and use it in GitHub Desktop.
Livereload via Gulp and Jekyll build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var cp = require('child_process'); | |
var shell = require('gulp-shell'); | |
var express = require('express'); | |
var livereload = require('gulp-livereload'); | |
gulp.task('default', ['watch']); | |
// Run static file server | |
gulp.task('serve', function () { | |
var server = express(); | |
server.use(express.static('_site')); | |
server.listen(4000); | |
}); | |
// Watch for changed files | |
gulp.task('watch', ['jekyll', 'serve'], function () { | |
// Create LiveReload server | |
livereload.listen({ port: 35729, basePath: '_site' }); | |
// Watch files, reload on change | |
gulp.watch('_site/**').on('change', function (file) { | |
livereload.changed(file.path); | |
}); | |
gulp.watch(['./*.html', '_layouts/*.haml', '_includes/*.haml', '**/*.md', '_sass/**/*.scss', './images/**/*', '!_site/**', '!_site/**/*'], ['jekyll']); | |
}); | |
// Compile pages with Jekyll | |
gulp.task('jekyll', function () { | |
return cp.spawn('jekyll', ['build']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment