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

roots-browserify

v0.7.0

Published

roots extension enabling the use of browserify

Downloads

10

Readme

Roots Browserify

npm tests coverage dependencies

Roots browserify is an alternate javascript pipeline that uses commonjs and browserify to build and concatenate scripts.

Note: This project is in early development, and versioning is a little different. Read this for more details.

Installation

  • make sure you are in your roots project directory

  • npm install roots-browserify --save

  • modify your app.coffee file to include the extension, as such

    browserify = require('roots-browserify')
    
    module.exports =
      extensions: [browserify(files: "assets/js/main.coffee", out: 'js/build.js')]

Usage

This extension very directly uses browserify's javascript API under the hood. For basic usage, pass either a string with a file path or an array of file path strings as entry points for browserify, and an output path where all the concatenated scripts should be written, as shown in the example above.

Injecting script into views

When you use this extension, it wille expose a function called browserify to all your view files. When you call this function, the extension will drop in one script tag pointing to your script.

The browserify function accepts one optional argument, which is a path to prefix any injected scripts with. So for example if you wanted to have the script load from the root of the site, you could pass in /. By default it would be the relative path js/build.js, but calling with / would make it /js/build.js.

Here's an example of using the browserify function. This example uses jade but this will also work with any other templating lagnuage.

//- index.jade
p here's my great website
!= browserify()

Now let's take a look at some sample output. With this configuration:

# app.coffee
browserify = require 'roots-browserify'

module.exports =
  extensions: [browserify(files: 'assets/js/main.coffee', out: 'js/build.js')]

You would see this output.

<!-- pulic/index.html -->
<p>here's my great website</p>
<script src="js/build.js"></script>

Options

files

String or array of strings pointing to one or more file paths which will serve as the base. See browserify docs for more info.

sourceMap

Generates an inline sourcemap, external if minify is true. Default is false.

minify

Minfifies the output. Default is false.

opts

Any additional options you'd like to be passed in to browserify. Again, documented here. Default is { extensions: ['.js', '.json', '.coffee'] }.

out

Where you want to output your built js file to in your public folder (or whatever you have set output to in the roots settings). There is no default. Recommended is js/build.js

transforms

If you'd like to add additional custom transforms, you can do it through this option. Pass either a transform function or an array of functions and they will be included in the pipeline. Default is coffeeify (add that string to your array if you want to keep coffeeify as well, otherwise it will be overridden).

License & Contributing