HTTP handler for serving browserify bundles
MIT License
HTTP handler for serving browserify bundles
var http = require("http")
var path = require("path")
// Simple http router
var Router = require("routes-router")
// Simple static file server
var ecstatic = require("ecstatic")
var ServeBrowserify = require("serve-browserify")
var router = 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.js
router.addRoute("/browserify/*", ServeBrowserify({
root: path.join(__dirname, "browser"),
base: "/browserify"
}))
// static server to serve html page for example
router.addRoute("/", ecstatic({
root: path.join(__dirname, "static"),
autoIndex: true
}))
var server = http.createServer(router)
server.listen(9024, function () {
console.log("demo server listening on port 9024")
})
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:
See serve-browserify --help
npm install serve-browserify