Skip to content

Instantly share code, notes, and snippets.

@gggritso
Created November 5, 2014 16:14
Show Gist options
  • Save gggritso/f8c3623edc2634107372 to your computer and use it in GitHub Desktop.
Save gggritso/f8c3623edc2634107372 to your computer and use it in GitHub Desktop.
Gulp + Superstatic

If you work on SPAs or any kind of static site, try Superstatic as a replacement for using python -m SimpleHTTPServer or Apache, or Anvil or whatever. It's really clean and user-friendly and it's sitting on top of Express, so it's easy to extend. Plus, since Gulp is awesome, it's easy to integrate Superstatic into your workflow. This is basically how I work on all my SPAs these days.

var
gulp = require( 'gulp' ),
superstatic = require( 'superstatic' );
gulp.task( 'server', function() {
var server = superstatic({
clean_urls: true,
routes: {
'/**': 'index.html',
'/src/**/*': '/src/'
}
});
server.listen( function() {
console.log( 'Server running on port ' + server.port );
});
});
@Jerome2606
Copy link

it doesn't work for me:

gulp server [11:39:49] Using gulpfile ~\testGulp\gulpfile.js [11:39:49] Starting 'server'... [11:39:49] 'server' errored after 30 ms [11:39:49] TypeError: undefined is not a function at Gulp.<anonymous> (C:\testGulp\gulpfile.js:17:10) at module.exports (C:\testGulp\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7) at Gulp.Orchestrator._runTask (C:\testGulp\node_modules\gulp\node_modules\orchestrator\index.js:273:3) at Gulp.Orchestrator._runStep (C:\testGulp\node_modules\gulp\node_modules\orchestrator\index.js:214:10) at Gulp.Orchestrator.start (C:\testGulp\node_modules\gulp\node_modules\orchestrator\index.js:134:8) at C:\testGulp\node_modules\gulp\bin\gulp.js:129:20 at process._tickCallback (node.js:355:11) at Function.Module.runMain (module.js:503:11) at startup (node.js:129:16) at node.js:814:3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment