There are already a couple of browserify plugins for metalsmith. However, none of them are quite right in my opinion. There are some that don't update the metalsmith files object, which means that you can't use metalsmith plugins to futher manipulate the resulting bundle. Others just have a cumbersome api or haven't been maintained.
So I created this plugin to address those issues. By allowing you to pass options directly to browserify it allows you to do everything you would normally do with browserify, like transforms, inline sourcemaps, etc. By adhering to metalsmith plugin conventions it works as you'd expect a metalsmith plugin to work.
$ npm install metalsmith-browserifi
- 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, so use wisely. The default is
The entry points that should be browserified. So this
Would browserify both
./src/another.js and output them as
Use this to pass options to browserify. So this
Would enable browserify's debug option, and add an inline source map as well.
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-browserifi. So if you normally run
metalsmith to build, use
DEBUG=metalsmith-browserifi metalsmith (on windows the syntax is slightly different).