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

bankai

Package Overview
Dependencies
Maintainers
4
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.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
109
decreased by-44.95%
Maintainers
4
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 css = assets.css()
const js = assets.js(browserify, client)
const html = assets.html()

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
    build       Build the application and write it to disk

    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]
      -d, --dir=<dir>        Write built application files to <dir>
      --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 build --dir=dist

    $ bankai build --dir=dist --html.title bankai

    $ bankai build --dir=dist --css.use sheetify-cssnext

    $ bankai build --dir=dist --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 20 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