npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-browserify

v1.1.0

Published

Metalsmith plugin to bundle JS with browserify

Downloads

37

Readme

metalsmith-browserify

npm version build status coverage status greenkeeper downloads

A metalsmith plugin to bundle javascript with browserify

This plugin allows you to bundle your javascript with browserify. Pass it the entry points it should bundle, and it will replace those files with the resulting bundle on build.

For support questions please use stack overflow or our slack channel. For browserify specific questions try their documentation.

Installation

$ npm install metalsmith-browserify

Options

You can pass options to metalsmith-browserify with the Javascript API or CLI. The options are:

  • entries: required. The entry points that need to be browserified. Accepts an array of strings.
  • browserifyOptions: optional. These options will be passed on to browserify. See this area of the browserify documentation for all available options. Note that it's possible to break stuff here, like overriding the entries or basedir, so use wisely.
  • suppressNotFoundError: optional. By default metalsmith-browserify will exit with an error if a file can't be found. Enabling this option will suppress that error.

entries

The entry points that should be browserified. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-browserify": {
      "entries": [
        "index.js",
        "another.js"
      ]
    }
  }
}

Would browserify both ./src/index.js and ./src/another.js and output them as ./build/index.js and ./build/another.js respectively.

Note that if the entry path is nested, the paths may differ across operating systems. Make sure you're using the correct directory separators, or use node's path.join to make sure the path will work anywhere.

browserifyOptions

Use this to pass options to browserify. So this metalsmith.json:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-browserify": {
      "entries": ["index.js"],
      "browserifyOptions": {
        "debug": true
      }
    }
  }
}

Would enable browserify's debug option and add a source map to the bundle.

suppressNotFoundError

metalsmith-browserify exits with an error if it can’t find an entry file. If you’re doing any kind of incremental builds via something like metalsmith-watch, this is problematic as you’re likely only rebuilding files that have changed. This flag allows you to suppress that error:

{
  "source": "src",
  "destination": "build",
  "plugins": {
    "metalsmith-browserify": {
      "entries": ["index.js"],
      "suppressNotFoundError": true
    }
  }
}

Note that when this option is turned on, if you're logging debug messages, you’ll still see a message denoting which files metalsmith-browserify cannot find.

Errors and debugging

If you're encountering problems you can use debug to enable verbose logging. To enable debug prefix your build command with DEBUG=metalsmith-browserify. So if you normally run metalsmith to build, use DEBUG=metalsmith-browserify metalsmith (on windows the syntax is slightly different).

License

MIT