Skip to content

Instantly share code, notes, and snippets.

@jdsimcoe
Last active September 25, 2015 15:28
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 jdsimcoe/ab5640a68f9830a1819e to your computer and use it in GitHub Desktop.
Save jdsimcoe/ab5640a68f9830a1819e to your computer and use it in GitHub Desktop.
Framer Server
var gulp = require('gulp');
var EXPRESS_PORT = 4000;
var EXPRESS_ROOT = __dirname;
var LIVERELOAD_PORT = 35729;
function startExpress() {
var express = require('express');
var app = express();
app.use(require('connect-livereload')());
app.use(express.static(EXPRESS_ROOT));
app.listen(EXPRESS_PORT);
}
var lr;
function startLivereload() {
lr = require('tiny-lr')();
lr.listen(LIVERELOAD_PORT);
}
function notifyLivereload(event) {
var fileName = require('path').relative(EXPRESS_ROOT, event.path);
lr.changed({
body: {
files: [fileName]
}
});
}
gulp.task('default', function () {
startExpress();
startLivereload();
gulp.watch('*.js', notifyLivereload);
gulp.watch('images/*.png', notifyLivereload);
});
{
"name": "framer-server",
"version": "0.0.1",
"description": "Local development environment for Framer.js prototypes",
"main": "app.js",
"dependencies": {
"connect-livereload": "~0.3.2",
"express": "~3.5.1",
"gulp": "~3.6.0",
"gulp-embedlr": "~0.5.2",
"gulp-livereload": "~1.2.0",
"tiny-lr": "~0.0.5"
},
"author": "Jonathan Simcoe"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment