Skip to content

Instantly share code, notes, and snippets.

@pibby
Created July 5, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pibby/2b8a21451dce40de05c6 to your computer and use it in GitHub Desktop.
Save pibby/2b8a21451dce40de05c6 to your computer and use it in GitHub Desktop.
Livereload via Gulp and Jekyll build
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