Skip to content

kublaj/metalsmith-browserify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Metalsmith - Browserify

Metalsmith plugin to bundle JS with browserify

Installation

npm install metalsmith-browserify --save

metalsmith-browserify does not bundle browserify. You need to install it yourself in your package. This is to avoid usage of an outdated browserify version with metalsmith-browserify.

Usage

var metalsmith = require('metalsmith');
var browserify = require('metalsmith-browserify');

metalsmith(__dirname)
  .use(browserify({
    dest: 'js/bundle.js',
    entries: ['./src/js/index.js'],
    sourcemaps: false,
    watch: false
  }))
  .build(function (err, files) {
    if (err) {
      throw err;
    }
  });

See browserify api for available options.

If you need to manipulate the created browserify bundle do:

var metalsmith = require('metalsmith');
var browserify = require('metalsmith-browserify');

var b = browserify({
  dest: 'js/bundle.js',
  entires: ['./src/js/index.js']
);

// do stuff with the bundle
b.bundle.external(/*...*/);

metalsmith(__dirname)
  .use(b) // use the plugin
  .build()

It can also be used with metalsmith.json by adding the plugin like this:

{
  "plugins": {
    "metalsmith-browserify": {
      "dest": "javascripts/bundle.js",
      "entries": ["src/javascripts/index.js"],
      "sourcemaps": false,
      "watch": false
    }
  }
}

Or assume the defaults (dest: bundle.js, args: []):

{
  "plugins": {
    "metalsmith-browserify": true
  }
}

About

Metalsmith plugin to bundle JS with browserify

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.6%
  • HTML 0.4%