bankai
DIY development server. Serves HTML, CSS and JS as streams. Sets proper
Content-Type
encodings and buffers where possible for sub-milisecond response
times in production and development.
Installation
$ npm install bankai
Usage
const sheetify = require('sheetify/stream')
const wayfarer = require('wayfarer')
const browserify = require('browserify')
const bankai = require('bankai')
const http = require('http')
const router = wayfarer()
http.createServer(function (req, res) {
router(req.url)(req, res).pipe(res)
}).listen(1337)
const html = bankai.html()
router.on('/', () => html)
const js = bankai.js(browserify, '/src/index.js', { transform: 'babelify' })
router.on('/bundle.js', () => js)
const css = bankai.css(sheetify, '/src/index.css')
router.on('/bundle.css', () => css)
API
bankai.html(opts)
Return an html
stream. Cached by default. Takes the following options:
- opts.entry:
js
entry point. Defaults to /bundle.js
- opts.css:
css
entry point. Defaults to /bundle.css
bankai.css(sheetify, src, opts)
Return a css
stream. sheetify
doesn't support incremental builds yet.
Cached if NODE_ENV=production
. Takes the following options:
- use: array of transforms. Empty by default.
- basedir: project base directory. Defaults to the dir part of
src
.
bankai.js(browserify, src, opts)
Return a js
stream. Uses watchify
for incremental builds if
NODE_ENV=development
. src
is the bundle entry file. Cached by default.
See Also
License
MIT