Last active
August 29, 2015 14:25
-
-
Save jhines2k7/dc2d364d5236301ba528 to your computer and use it in GitHub Desktop.
Gulp live reload example
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'); | |
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