Skip to content

Instantly share code, notes, and snippets.

@jhines2k7
Last active August 29, 2015 14:25
Show Gist options
  • Save jhines2k7/dc2d364d5236301ba528 to your computer and use it in GitHub Desktop.
Save jhines2k7/dc2d364d5236301ba528 to your computer and use it in GitHub Desktop.
Gulp live reload example
var gulp = require('gulp');
function startExpress() {
var express = require('express');
var app = express();
app.use(require('connect-livereload')());
app.use(express.static(__dirname));
app.listen(8080);
}
var lr;
function startLivereload() {
lr = require('tiny-lr')();
lr.listen(35729);
}
function notifyLivereload(event) {
var fileName = require('path').relative(__dirname, event.path);
lr.changed({
body: {
files: [fileName]
}
});
}
gulp.task('default', function() {
startExpress();
startLivereload();
gulp.watch(['*.html', 'css/*.css'], notifyLivereload);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment