Skip to content

Instantly share code, notes, and snippets.

@youweit
Created June 2, 2015 08:12
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 youweit/aa428b27143e2d83018a to your computer and use it in GitHub Desktop.
Save youweit/aa428b27143e2d83018a to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
path = require('path'),
EXPRESS_ROOT = path.join(__dirname, 'app');
var startExpress = function() {
var server = require('./server.js');
server({
dir:EXPRESS_ROOT,
port: 9898
});
}
var startLiveReload = function() {
var lr = require('tiny-lr')();
lr.listen(35729);
return lr;
}
var notifyLivereload = function(event, lr) {
var fileName = require('path').relative(EXPRESS_ROOT, event.path);
lr.changed({
body: {
files: [fileName]
}
});
}
// `gulp.task()` defines task that can be run calling `gulp xyz` from the command line
// The `default` task gets called when no task name is provided to Gulp
gulp.task('default', function () {
startExpress();
var lr = startLiveReload();
gulp.watch('app/**', function(event){
notifyLivereload(event, lr);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment