Skip to content

Instantly share code, notes, and snippets.

@zoncoen
Created May 15, 2014 15:50
Show Gist options
  • Save zoncoen/2c34de22166f9143aa8c to your computer and use it in GitHub Desktop.
Save zoncoen/2c34de22166f9143aa8c to your computer and use it in GitHub Desktop.
LiveReload with gulp.
var gulp = require('gulp'),
express = require('express'),
connect_livereload = require('connect-livereload'),
livereload = require('gulp-livereload');
var EXPRESS_PORT = 4000;
var EXPRESS_ROOT = __dirname;
function startExpress() {
var app = express();
app.use(connect_livereload());
app.use(express.static(EXPRESS_ROOT));
app.listen(EXPRESS_PORT);
}
gulp.task('watch', function() {
startExpress();
var server = livereload();
gulp.watch(['static/**']).on('change', function(file) {
server.changed(file.path);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment