Home

Awesome

beefy

a local development server designed to work with browserify.

it:

how do I get it?

npm install -g beefy; and if you want to always have a browserify available for beefy to use, npm install -g browserify.

usage

$ cd directory/you/want/served
$ beefy path/to/thing/you/want/browserified.js [PORT] [-- browserify args]

what bundler does it use?

Beefy searches for bundlers in the following order:

path/to/file.js

the path to the file you want browserified. can be just a normal node module. you can also alias it: path/to/file.js:bundle.js if you want -- so all requests to bundle.js will browserify path/to/file.js. this is helpful for when you're writing gh-pages-style sites that already have an index.html, and expect the bundle to be pregenerated and available at a certain path.

You may provide multiple entry points, if you desire!

--browserify command

--bundler command

use command instead of browserify or ./node_modules/.bin/browserify.

in theory, you could even get this working with r.js, but that would probably be scary and bats would fly out of it. but it's there if you need it! if you want to use r.js with beefy, you'll need a config that can write the resulting bundle to stdout, and you can run beefy with beefy :output-url.js --bundler r.js -- -o config.js.

NB: This will not work in Windows.

--live

Enable live reloading. this'll start up a sideband server and an fs watch on the current working directory -- if you save a file, your browser will refresh.

if you're not using the generated index file, beefy has your back -- it'll still automatically inject the appropriate script tag.

    <script src="/-/live-reload.js"></script>

--cwd dir

serve files as if running from dir.

--debug=false

turn off browserify source map output. by default, beefy automatically inserts -d into the browserify args -- this turns that behavior off.

--open

automatically discover a port and open it using your default browser.

--index=path/to/file

Provide your own default index! This works great for single page apps, as every URL on your site will be redirected to the same HTML file. Every instance of {{entry}} will be replaced with the entry point of your app.

api

var beefy = require('beefy')
  , http = require('http')

var handler = beefy('entry.js')

http.createServer(handler).listen(8124)

Beefy defaults the cwd to the directory of the file requiring it, so it's easy to switch from CLI mode to building a server.

As your server grows, you may want to expand on the information you're giving beefy:

var beefy = require('beefy')
  , http = require('http')

http.createServer(beefy({
    entries: ['entry.js']
  , cwd: __dirname
  , live: true
  , quiet: false
  , bundlerFlags: ['-t', 'brfs']
  , unhandled: on404
})).listen(8124)

function on404(req, resp) {
  resp.writeHead(404, {})
  resp.end('sorry folks!')
}

beefy(opts: BeefyOptions, ready: (err: Error) => void)

Create a request handler suitable for providing to http.createServer. Calls ready once the appropriate bundler has been located. If ready is not provided and a bundler isn't located, an error is thrown.

BeefyOptions

Beefy's options are a simple object, which may contain the following attributes:

Beefy may accept, as a shorthand, beefy("file.js") or beefy(["file.js"]).

license

MIT