Skip to content

Instantly share code, notes, and snippets.

@keik
Created June 30, 2015 11:52
Show Gist options
  • Save keik/67d7ab420e087d34dec3 to your computer and use it in GitHub Desktop.
Save keik/67d7ab420e087d34dec3 to your computer and use it in GitHub Desktop.
gulp.task('connect', function() {
connect.server({
port: 8888,
middleware: function (connect, opt) {
return [
function (req, res, next) {
var urlobj = url.parse(req.url);
var filename = __dirname + urlobj.pathname + (urlobj.pathname.substr(-1) === '/' ? 'index.html' : '');
if (!filename.match(/\.s?html$/)) {
next();
} else {
res.end(ssi.parse(filename, fs.readFileSync(filename, {encoding: 'utf8'})).contents);
}
}
];
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment