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-alt

v2.0.0

Published

Minimal configuration Browserify integration for Metalsmith

Downloads

19

Readme

metalsmith-browserify-alt

Minimal configuration Browserify integration for Metalsmith

This plugin lets you use Browserify to compile JavaScript for your Metalsmith sites.

Status

Installation

Install this npm package alongside browserify.

npm install --save --save-exact metalsmith-browserify-alt browserify

Usage

  1. Add the metalsmith-browserify-alt plugin to your metalsmith.js or metalsmith.json.
/* metalsmith.json */

{
  "source": "./src",
  "destination": "./public",
  "plugins": {
    "metalsmith-sense-browserify": {}
  }
}
  1. In your source directory, create a file named [NAME].browserify.js (replace [NAME] with your choice of filename). It will be compiled into [NAME].js.
/* src/app.browserify.js */

// This will compile into `app.js`.
// Below are the options to be passed onto Browserify.
// The `entries` option defines what input file will be parsed.

module.exports = {
  entries: [ __dirname + '/../js/app.js' ],
  transform: [ 'babelify' ]
}
  1. The actual file to be compiled by Browserify is defined in the entries option above. (It's recommended that these files not be placed inside the Metalsmith source directory to avoid being compiled on its own.)
/* js/app.js */

alert('Hello from browserify!')

API

require('metalsmith-sense-browserify')(options)

Returns a Metalsmith plugin for compiling *.browserify.js files via Browserify. options is optional.

Compiling files

The *.browserify.js files are expected to be files that will return an Object or a Function. If it's an Object, it will be passed onto browserify(...). If it's a function, it's assumed to return a browserify() instance.

// src/example.browserify.js
module.exports = { entries: [__dirname + '/../js/app.js'] }

See browserify docs for full details on options you can use. Common options include:

  • entries — entry points for the JS bundle.
  • transform — array of transform functions or module names.
  • plugin - array of plugin functions or module names.
  • extensions — array to be parsed; defaults to ['js', 'json'].
  • standalone — provides a UMD build if true.
  • debug — adds source maps if true.

Setting defaults

Set options.defaults to set options that will be used on all .browserify.js files.

See below for recommended options. This enables source maps and watchify for fast rebuilds (great with metalsmith-start).

Metalsmith(__dirname)
  .use(require('metalsmith-sense-browserify')({
    defaults: {
      cache: {},
      packageCache: {},
      transform: ['babelify'],
      plugin: process.env.NODE_ENV === 'development' ? ['watchify'] : []
      debug: process.env.NODE_ENV === 'development'
    }
  })

Extras

var app = Metalsmith(__dirname)
  .source('./src')
  .destination('./public')
  .use(require('metalsmith-sense-browserify')({
    defaults: {
      cache: {},
      packageCache: {},
      transform: ['babelify'],
      plugin: process.env.NODE_ENV === 'development' ? ['watchify'] : [],
      debug: process.env.NODE_ENV === 'development'
    }
  })


if (module.parent) {
  module.exports = app
} else {
  app.build(function (err) { if (err) { console.error(err); process.exit(1) } })
}

Prior art

This package is an alternative to metalsmith-browserify. Unlike that plugin:

  • You can configure browserify bundles in Metalsmith source files rather than in metalsmith.js.
  • You may also have full programmatic control over browserify().

Thanks

metalsmith-browserify-alt © 2016+, Rico Sta. Cruz. Released under the MIT License. Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz