Browserify Recipes

September 2, 2016

Creating require module in the browser

var browserify = require('browserify')

browserify()
  .require(src.main, {expose: module.shortcut})
  .bundle()

Creating global module in the browser

var browserify = require('browserify')
browserify(src.vanilla, {standalone: module.shortcut})
  .bundle()

Applying transpilers (like CoffeeScript, TypeScript, Babel,…)

var browserify = require('browserify')
var coffeeify = require('coffeeify')

browserify extensions: ['.coffee', '.js']
  .transform coffeeify, global: true
  .require(src.main, { expose: module.shortcut})
  .ignore('coffee-script')
  .bundle()