Created
May 7, 2015 08:42
-
-
Save tsq/9d5501df89bc28372292 to your computer and use it in GitHub Desktop.
simple livereload
This file contains hidden or 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 gutil = require('gulp-util'); | |
var express = require('express'); | |
var path = require('path'); | |
var tinylr = require('tiny-lr'); | |
var createServers = function(port, lrport) { | |
var lr = tinylr(); | |
lr.listen(lrport, function() { | |
gutil.log('LR Listening on', lrport); | |
}); | |
var app = express(); | |
app.use(express.static(path.resolve('./'))); | |
app.listen(port, function() { | |
gutil.log('Listening on', port); | |
}); | |
return { | |
lr: lr, | |
app: app | |
}; | |
}; | |
// use for development | |
gulp.task('dev', function () { | |
var servers = createServers(8088, 35729); | |
gulp.watch(["./**/*.html","./**/*.js","./**/*.css", "!./node_modules/**/*"], function(evt){ | |
gutil.log(gutil.colors.cyan(evt.path), 'changed'); | |
servers.lr.changed({ | |
body: { | |
files: [evt.path] | |
} | |
}); | |
}); | |
}); | |
gulp.task('default', ['dev'], function(){ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment