Skip to content

Instantly share code, notes, and snippets.

@marr
Last active August 29, 2015 13:57
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 marr/9802975 to your computer and use it in GitHub Desktop.
Save marr/9802975 to your computer and use it in GitHub Desktop.
var gulp = require('gulp'), livereload = require('gulp-livereload'),
gutil = require('gulp-util'),
dest = 'build';
gulp.task('staticsvr', function(next) {
var staticS = require('node-static'),
server = new staticS.Server('./' + dest),
port = 8000;
require('http').createServer(function (request, response) {
request.addListener('end', function () {
server.serve(request, response);
}).resume();
}).listen(port, function() {
gutil.log('Server listening on port: ' + gutil.colors.magenta(port));
next();
});
});
gulp.task('watch', ['staticsvr'], function() {
var server = livereload();
gulp.watch(dest + '/**').on('change', function(file) {
server.changed(file.path);
});
});
{
"name": "gulpsrv",
"version": "0.0.0",
"description": "",
"main": "gulpfile.js",
"dependencies": {
"gulp": "~3.5.6",
"gulp-livereload": "~1.2.0",
"gulp-util": "~2.2.14",
"node-static": "~0.7.3"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gist.github.com/koistya/574822628b372f8004bd.git"
},
"author": "",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://gist.github.com/koistya/574822628b372f8004bd"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment