Skip to content

Instantly share code, notes, and snippets.

@chrisjlee
Created June 3, 2014 05:26
Show Gist options
  • Save chrisjlee/9b703bfce8dd18ce1c99 to your computer and use it in GitHub Desktop.
Save chrisjlee/9b703bfce8dd18ce1c99 to your computer and use it in GitHub Desktop.
var gulp = require("gulp");
var path = require("path");
var server = {
port: 4000,
livereloadPort: 35729,
basePath: path.join(__dirname, "www"),
_lr: null,
start: function () {
var express = require('express');
var app = express();
app.use(require('connect-livereload')());
app.use(express.static(this.basePath));
app.listen(this.port);
},
livereload: function () {
this._lr = require('tiny-lr')();
this._lr.listen(this.livereloadPort);
},
livestart: function () {
this.start();
this.livereload();
},
notify: function (event) {
var fileName = path.relative(this.basePath, event.path);
this._lr.changed({
body: {
files: [fileName]
}
});
}
};
gulp.task("default", function () {
server.livestart();
gulp.watch("www/**/*.html", function (event) {
server.notify(event);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment