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-channel-builder

v0.1.6

Published

Grunt plugin for outputting multiple applications by channel based on shared and unshared code residing in the same repository.

Readme

grunt-channel-builder

Grunt plugin for creating multiple applications by channel based on shared and unshared code residing in the same repository. Developed to work with ngbp but allow the ability to have targetted custom output builds per client/region.

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-channel-builder --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-channel-builder');

The "channel_builder" task

Overview

In your project's Gruntfile, add a section named channel_builder to the data object passed into grunt.initConfig().

grunt.initConfig({
    channel_builder: {
        options: {
            defaultChannelName: '',
            filePatterns: {
                js: '',
                less: '',
                tpl: ''
            }
        },
        your_target: {
            replaceConfigValue: [{
                existingConfigValueToReplace: '',
                filePatternOfSourceList: ''
            }]
            folderNamePattern: ''
        }
    }
});

Options

Options are recursive so custom options can be placed on any specific channel.

options.defaultChannelName

Type: String Default value: default

A string value that represents the name of the channel that does not have a folder name pattern and only has files that match none of the channels.

options.filePatterns

Type: Object Default value: { js: ['src/**/*.js','!src/**/*.spec.js'], less: 'src/**/*.less', tpl: 'src/**/*.tpl.html' }

An object of the file patterns that will be collected for each channel. Each file type can be a string glob match pattern or an array of them.

options.replaceConfigValues

Type: Array Default value: '[]'

An optional array of objects allowing channel_builder to automatically replace existing config values, like one already in your build process, with the results of the channel build for a specific channel and file pattern.

options.replaceConfigValues[n].existingConfigValueToReplace

Type: String

An optional object that sets up a config change at the end of the individual channel task, this value is the name of the existing config value that will be replaced.

options.replaceConfigValues[n].filePatternOfSourceList

Type: String

An optional object that sets up a config change at the end of the individual channel task, this value is the name of the file pattern whose list will replace the existing config value.

channel.folderNamePattern

Type: String

Each channel has a folder name pattern that will include or exclude files that match the file pattern if that file is in either a subfolder that has the pattern in the folder name or a common file that belongs to all channels. The only exception is the 'default' channel which will list files that don't match any other channel.

Usage Examples

Setup

Create any number of channels and give each one of them a folder name pattern. Keep your code structure how ever you want and by placing the file in a subfolder that has the channel's folder name pattern anywhere in the name (but seperated by a non-word character) it will be automatically added to the channel_builder config object ready to be fed into grunt-contrib-concat task or any other task.

ie_file_list: ['test/fixtures/**/*.js','!test/fixtures/**/*.spec.js'],
channel_builder: {
  options: {
    filePatterns : {
        js: ['test/fixtures/**/*.js','!test/fixtures/**/*.spec.js'],
        less: 'test/fixtures/**/*.less',
        tpl: 'test/fixtures/**/*.tpl.html'
    }
  },
  ireland: {
      options: {
          replaceConfigValues: [{
            existingConfigValueToReplace: 'ie_file_list',
            filePatternOfSourceList: 'js'
          }]
      },
      folderNamePattern: 'ie',
  },
  brazil: {
      folderNamePattern: 'br',
  },
  acme: {
      folderNamePattern: 'acm',
  },
  default: {
      // put nothing in here
  }
}

Result

In this example, excecuting the task channel_builder adds an out property that can be called using grunt templates feeding into the concat task.

ie_file_list: [
        "test/fixtures/coolness/br-ie/coolnessfile.js",
        "test/fixtures/ie/mainfeature1.js",
        "test/fixtures/mainfeature2.js",
        "test/fixtures/wonder/awesome/ie/awesome.js",
        "test/fixtures/wonder/wonderfile.js"
      ],
channel_builder: {
  "options": {
    "filePatterns": {
      "js": [
        "test/fixtures/**/*.js",
        "!test/fixtures/**/*.spec.js"
      ],
      "less": "test/fixtures/**/*.less",
      "tpl": "test/fixtures/**/*.tpl.html"
    }
  },
  "ireland": {
    "options": {
      "replaceConfigValues": [
        {
          "existingConfigValueToReplace": "ie_file_list",
          "filePatternOfSourceList": "js"
        }
      ]
    },
    "folderNamePattern": "ie"
  },
  "brazil": {
    "folderNamePattern": "br"
  },
  "acme": {
    "folderNamePattern": "acm"
  },
  "default": {},
  "out": {
    "ireland": {
      "js": [
        "test/fixtures/coolness/br-ie/coolnessfile.js",
        "test/fixtures/ie/mainfeature1.js",
        "test/fixtures/mainfeature2.js",
        "test/fixtures/wonder/awesome/ie/awesome.js",
        "test/fixtures/wonder/wonderfile.js"
      ],
      "less": [
        "test/fixtures/coolness/br-ie/coolnessfile.less",
        "test/fixtures/ie/mainfeature1.less"
      ],
      "tpl": [
        "test/fixtures/coolness/coolnessfile.tpl.html",
        "test/fixtures/ie/mainfeature1.tpl.html",
        "test/fixtures/mainfeature2.tpl.html"
      ]
    },
    "brazil": {
      "js": [
        "test/fixtures/coolness/br-ie/coolnessfile.js",
        "test/fixtures/mainfeature1.js",
        "test/fixtures/mainfeature2.js",
        "test/fixtures/wonder/acm br/wonderfile.js",
        "test/fixtures/wonder/awesome/awesome.js"
      ],
      "less": [
        "test/fixtures/coolness/br-ie/coolnessfile.less",
        "test/fixtures/mainfeature1.less"
      ],
      "tpl": [
        "test/fixtures/coolness/coolnessfile.tpl.html",
        "test/fixtures/mainfeature1.tpl.html",
        "test/fixtures/mainfeature2.tpl.html"
      ]
    },
    "acme": {
      "js": [
        "test/fixtures/coolness/coolnessfile.js",
        "test/fixtures/mainfeature1.js",
        "test/fixtures/mainfeature2.js",
        "test/fixtures/wonder/acm br/wonderfile.js",
        "test/fixtures/wonder/awesome/awesome.js"
      ],
      "less": [
        "test/fixtures/mainfeature1.less"
      ],
      "tpl": [
        "test/fixtures/coolness/coolnessfile.tpl.html",
        "test/fixtures/mainfeature1.tpl.html",
        "test/fixtures/mainfeature2.tpl.html"
      ]
    },
    "default": {
      "js": [
        "test/fixtures/coolness/coolnessfile.js",
        "test/fixtures/mainfeature1.js",
        "test/fixtures/mainfeature2.js",
        "test/fixtures/wonder/awesome/awesome.js",
        "test/fixtures/wonder/wonderfile.js"
      ],
      "less": [
        "test/fixtures/mainfeature1.less"
      ],
      "tpl": [
        "test/fixtures/coolness/coolnessfile.tpl.html",
        "test/fixtures/mainfeature1.tpl.html",
        "test/fixtures/mainfeature2.tpl.html"
      ]
    }
  }
}

So following the above example, you can use the template <%= channel_builder.out.acme.js %> to get a list of javascript files that are specific to the acme channel that you can feed into your other processes. In the case of the ireland channel we are replacing the ie_files_list config property with the output of Ireland channel's js file list, this replacement can be done on any channel and any file pattern.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Changelog

CHANGELOG.md