serve-browserify
HTTP handler for serving browserify bundles
Example
var http = var path = // Simple http routervar Router = // Simple static file servervar ecstatic = var ServeBrowserify = var router = // ServeBrowserify(opts) returns a http handler// to server browserified bundles. The suggestion is to// server /browserify/foo as /browser/foo/index.js or// /browserify/bar as /browser/bar.js// also /browserify/x/y as /browser/x/y.jsrouter// static server to serve html page for examplerouter var server = http server
Documentation
ServeJavascript(opts?)
type RequestHandler := (req: HttpRequest, res: HttpResponse) serve-browserify := ({ root: String, base: String?, cache: Boolean?, gzip: Boolean?, cacheControl: String?, debug: Boolean?}) => RequestHandler
ServeJavascript returns a function when given a root and opts will serve javascript files through browserify
Valid options are:
- root: The root folder location where it should look for javascript files to browserify & serve
- base: The base HTTP path where you are serving your assets from. This is only needed if you want to serve nested files
- cache: This will cache if enabled, which means every location browserify bundle get's cached after initial compilation. This also enables ETag's & HTTP caching
- gzip: This will enable gzipping the bundle and sending it as gzip'd encoded data to browsers if their accept-encoding matches
- cacheControl: This is a string you can set for the cache control header. It defaults to 'max-age=300, must-revalidate'
- debug: This is an option passed to browserify, when debug is set, browserify will embed source maps. Disable this in production to decrease file size
Cli
See serve-browserify --help
Installation
npm install serve-browserify
Contributors
- Raynos