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 🙏

© 2026 – Pkg Stats / Ryan Hefner

grunt-watchify

v0.1.0

Published

Browserify your code

Downloads

682

Readme

grunt-watchify

Grunt task for node-browserify.

Getting Started

This plugin requires Grunt ~0.4.0 and Node >=0.10.x.

Install this grunt plugin with:

npm install grunt-watchify --save-dev

Then add this line to your project's Gruntfile.js Gruntfile:

grunt.loadNpmTasks('grunt-watchify');

Differences with grunt-browserify

  • grunt-watchify watches the dependencies like watchify and rebuilds the bundle, when one dependency is modified.
  • grunt-watchify caches the dependencies making the rebuild process very fast (useful for big projects).
  • The configuration is different. You have the options of browserify plus keepalive and callback.
  • The instance of browserify is passed to callback where you can use the api of browserify. Remember to return the instance.
  • The keepalive is usefull if use grunt-watchify alone. It works like in grunt-contrib-connect#keepalive.
watchify: {
  options: {
    // defaults options used in b.bundle(opts)
    detectGlobals: true,
    insertGlobals: false,
    ignoreMissing: false,
    debug: false,
    standalone: false,

    keepalive: false,
    callback: function(b) {
      // configure the browserify instance here
      b.add(...);
      b.require(...);
      b.external(...);
      b.ignore(...);
      b.transform(...);

      // return it
      return b;
    }
  }
  example: {
    src: './src/**/*.js',
    dest: 'app/js/bundle.js'
  }
}
  • The src makes difference between process and ./process:
watchify: {
  example: {
    src: ['process', './src/**/*.js'],
    dest: 'app/js/bundle.js'
  },
}

Your project files start usually with ./.

  • You can use the glob only with your project files.

Examples

You find this example in the directory example.

  • grunt-watchify builds the bundle.js and watches the dependencies.
  • grunt-contrib-watch watches the bundle.js and triggers livereload when it changes.
  • grunt-contrib-connect serves the files.
  • grunt-contrib-livereload is used only for the livereload snippet.
/*
 * grunt-watchify
 * http://github.com/amiorin/grunt-watchify
 *
 * Copyright (c) 2013 Alberto Miorin, contributors
 * Licensed under the MIT license.
 */

'use strict';

var path = require('path');

var lrSnippet  = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function(connect, dir) {
  return connect.static(path.resolve(dir));
};

module.exports = function(grunt) {
  grunt.initConfig({

    watchify: {
      example: {
        src: './src/**/*.js',
        dest: 'app/js/bundle.js'
      },
    },

    watch: {
      app: {
        files: 'app/js/bundle.js',
        options: {
          livereload: true
        }
      }
    },

    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, 'app')
            ];
          }
        }
      }
    }
  });

  grunt.loadTasks('../tasks');

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-livereload');

  grunt.registerTask('default', ['watchify', 'connect', 'watch']);
};

How can you start grunt:

# with other tasks like connect and watch
# done() is called
grunt

# alone like watchify
# done() is *never* called
grunt watchify:example:keepalive

Credits