connect-browserify

Connect/express middleware for serving apps to a browser with browserify

npm install connect-browserify
12 downloads in the last day
61 downloads in the last week
283 downloads in the last month

Connect/express middelware for serving front-end applications with browserify. Install via npm:

npm install connect-browserify

Basic usage is as follows:

var express = require('express');
var browserify = require('connect-browserify');

app = express();
app.use('/js/app.js', browserify({
  entry: 'src/app.js',            // entry for your application

  requirements: ['src/views.js'], // additional modules to require, will
                                  // be exposed under id relative to
                                  // entry, e.g. './views' in current
                                  // example

  transforms: ['coffeeify'],        // transforms to use

  bundle: function(bundle) {      // optional, configure browserify instance
    // configure bundle
    return bundle
  },

  contentType: 'text/javascript', // optional, Content-type header to use, by
                                  // default this equals to 'application/javascript'

  extensions: ['.js', '.coffee'], // to consider non-js files as
                                  // CommonJS modules

  debug: true                     // see browserify docs, other options are
}));

app.listen(3000);

This middleware will start watching directory of entry file for changes and rebuild bundle accordingly and caching the result for future requests.

You should never use this middleware in production — use nginx for serving pre-built bundles to a browser.

viewcount

npm loves you