Socket
Socket
Sign inDemoInstall

bankai

Package Overview
Dependencies
Maintainers
7
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bankai

DIY asset server


Version published
Weekly downloads
194
increased by158.67%
Maintainers
7
Weekly downloads
 
Created
Source

bankai

Streaming asset compiler
Bundle and optimize CSS, HTML and JS

API stability NPM version Build Status Test Coverage Downloads Standard

Features

  • Thin wrapper around browserify in ~100 lines
  • CLI supports HTTP and Filesystem
  • Incremental compilation & build caching
  • Sensible defaults make it easy to use
  • Optimization mode for production grade artifacts

Usage

  Usage:
    $ bankai <command> [options]

  Commands:
    <default>                      Run 'bankai start'
    start <filename>               Start a bankai server
    build <filename> <directory>   Compile and export files to a directory

    Options:
      -c, --css=<subargs>     Pass subarguments to sheetify
      -d, --debug             Include sourcemaps [default: false]
      -e, --electron          Enable electron mode for the bundler
      -h, --help              Print usage
      -H, --html=<subargs>    Pass subarguments to create-html
      -j, --js=<subargs>      Pass subarguments to browserify
      -o, --open=<browser>    Open html in a browser [default: system default]
      -O, --optimize          Optimize assets served by bankai [default: false]
      -p, --port=<n>          Bind bankai to a port [default: 8080]
      -V, --verbose           Include debug messages

  Examples:
    $ bankai index.js -p 8080            # start bankai on port 8080
    $ bankai index.js --open             # open html in the browser
    $ bankai -c [ -u sheetify-cssnext ]  # use cssnext in sheetify
    $ bankai -j [ -t brfs ]              # use brfs in browserify
    $ bankai build index.js dist/        # compile and export to dist/
    $ bankai build -O index.js dist/     # optimize compiled files

JS Usage

Given the following client.js:

var css = require('sheetify')
var html = require('bel')

var prefix = css`
  :host > h1 { font-size: 12rem }
`

var el = html`
  <section class=${prefix}>
    <h1>hello planet</h1>
  </section>
`

document.body.appendChild(el)

Render with server.js:

var bankai = require('bankai')
var http = require('http')
var path = require('path')

var clientPath = path.join(__dirname, 'client.js')
var assets = bankai(clientPath)

http.createServer(function (req, res) {
  switch (req.url) {
    case '/': return assets.html(req, res).pipe(res)
    case '/bundle.js': return assets.js(req, res).pipe(res)
    case '/bundle.css': return assets.css(req, res).pipe(res)
    default: return (res.statusCode = 404) && res.end('404 not found')
  }
}).listen(8080)

API

assets = bankai(entryFile, [opts])

Create a new instance of bankai. The first argument is a route to the entry file that is compiled by browserify. The second argument is optional and can take the following options:

  • opts.js: (default: {}). Pass options to browserify. Cannot be disabled
  • opts.css: (default: {}). Pass options to sheetify. Set to false to disable
  • opts.html: (default: {}). Pass options to create-html. Set to false to disable
  • opts.optimize: (default false). Disable livereload scripts, cache output and optimize all bundles
  • opts.watch: Disable livereload scripts
  • opts.electron: (default false). Enable electron mode for the bundler. Relies on index.html being served as a static file using file:// to ensure require() paths are resolved correctly

readableStream = assets.js([req], [res])

Return a js stream. Sets correct header values if req and res are passed. Uses browserify and watchify under the hood.

readableStream = assets.html([req], [res])

Return a html stream. Sets correct header values if req and res are passed. Uses create-html under the hood.

readableStream = assets.css([req], [res])

Return a css stream. Sets correct header values if req and res are passed. Uses sheetify under the hood.

Installation

$ npm install bankai

See Also

Similar Packages

License

MIT

Keywords

FAQs

Package last updated on 21 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc