Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bankai

Package Overview
Dependencies
Maintainers
3
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bankai

DIY asset server

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
109
decreased by-44.95%
Maintainers
3
Weekly downloads
 
Created
Source

bankai stability

npm version build status test coverage downloads js-standard-style

DIY asset 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 browserify = require('browserify')
const bankai = require('bankai')
const http = require('http')
const path = require('path')

const client = path.join(__dirname, 'client.js')

const assets = bankai()
const js = assets.js(browserify, client)
const html = assets.html()
const css = assets.css()

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

API

assets = bankai(opts?)

  • optimize: default false. Disable livereload scripts, cache output and optimize all bundles.

assets.html(opts?)

Return an html stream. Takes the following options:

  • opts.entry: js entry point. Defaults to /bundle.js
  • opts.css: css entry point. Defaults to /bundle.css

assets.css(opts?)

Return a css stream using sheetify. . Takes the following options:

  • use: array of transforms. Empty by default.
  • basedir: project base directory. Defaults to process.cwd()

assets.js(browserify, src, opts?)

Return a js stream. src is the bundle entry file. opts are passed directly to browserify

CLI

$ node ./bin/ --help

  DIY asset server

  Usage
    $ bankai <command> [options]

  Commands
    start       Start a bankai server

    Options
      -e, --entry=<id>       Resolve <id> from cwd and use as entry module [default: .]
                             Entry module is expected to export `() -> app`
      -p, --port=<n>         Bind bankai to <n> [default: 1337]
      -o, --optimize         Optimize the page and all assets served by bankai [default: false]
      -b, --browse=<app>     Browse the page served by bankai with <app> [default: false]
      --html.entry=<uri>     Serve client js at <uri> [default: bundle.js]
      --html.css=<uri>       Serve client css at <uri> [default: bundle.css]
      --html.favicon         Disable favicon [default: true]
      --html.title           Title to use for page
      --html.lang            Lang attribute to use [default: en]
      --css.use              sheetify plugins to use
      --js.<opt>=<value>     Pass key <opt> with <value> to browserify

  Examples
    $ bankai start
    Started bankai for index.js on http://localhost:1337

    $ bankai start --entry=basic
    Started bankai fro basic/index.js on http://localhost:1337

    $ bankai start --port=3000
    Started bankai for index.js on http://localhost:3000

    $ bankai start --open
    Started bankai for index.js on http://localhost:1337
    Opening http://localhost:1337 with default browser

    $ bankai start --open Safari
    Started bankai for index.js on http://localhost:1337
    Opening http://localhost:1337 with system browser

    $ bankai start --html.title bankai
    Started bankai for index.js on http://localhost:1337

    $ bankai start --css.use sheetify-cssnext
    Started bankai for index.js on http://localhost:1337

    $ bankai start --js.fullPaths=false

Examples

Projects showing exemplary usage are provided. Install root project dependencies, example project dependencies and execute npm start to start an example.

  • Basic - Showing default settings, Hot Module Replacement

See Also

License

MIT

Keywords

FAQs

Package last updated on 10 Aug 2016

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