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

grunt-task-loader

v0.6.0

Published

A grunt task loader for Grunt.

Downloads

90

Readme

grunt-task-loader

Build Status NPM version

Speed up task loading and load npm grunt tasks automatically

Before:

// gruntfile.js
module.exports = function(grunt) {

  // configure tasks

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-...');
  grunt.loadTasks('foo');
  grunt.loadTasks('bar');
  grunt.loadTasks('...');
}

After:

// gruntfile.js
module.exports = function(grunt) {

  require('grunt-task-loader')(grunt);

  // configure tasks
}

Sample time output before:

// output by time-grunt
Execution Time (2014-10-14 07:32:26 UTC)
loading tasks  6.7s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 98%
reset           130ms  ▇▇ 2%
Total 6.83s

Sample time output after:

Execution Time (2014-10-14 07:33:32 UTC)
loading tasks  156ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 52%
loading reset   14ms  ▇▇▇ 5%
reset           130ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 43%
Total 318ms

Install

npm install grunt-task-loader --save-dev

Usage

Simple:

// Must go at the top of your gruntfile, before the task config.
require('grunt-task-loader')(grunt);

With Options:

require('grunt-task-loader')(grunt, {
  customTasksDir: '__CUSTOM_DIR__',   // or ['__CUSTOM_DIR__'],
  mapping: {
    taskA: 'another_tasks_dirs/', // custom task 'taskA' from custom tasks directory (load by grunt.loadTasks API)
    taskB: 'ultraman/frog.js',    // custom task from file
    cachebreaker: 'grunt-cache-breaker' // taskname mapping to package-name. will look in node_modules.
  }
});

Options

customTasksDir

  • Type: string,array
  • Default: []

mapping

  • Type: object
  • Default: {}

Key is the grunt task name (as referenced in grunt config for that task), and value is the name of that task's package as it can be found in the filesystem.

mappingExample:
require('grunt-task-loader')(grunt, {
  mapping: {
    express: 'grunt-express-server'
  }
});

convertCamelCase

  • Type: boolean
  • Default: true

Automatically handles grunt tasks whose task names have been defined in camelCase while their package names are in param-case (this could also be handled per-task in custom mappings). Examples: ngAnnotate, includeSource, etc.

See Gruntfile.js for more live examples.

Help: task not found

grunt-task-loader optimizes task loading by only loading the tasks needed for the current task list, instead of loading all of the 'grunt-' prefixed tasks in the package.json. To do this, it reads the task names from the grunt config. Sometimes, grunt task authors give the grunt task a name that doesn't correspond to the npm package they publish the plugin under. Example: grunt-express-server is configured with:

grunt.initConfig({
  express: { // not express-server
    // options
  }
});

So in this case, pass the name mapping in the options argument to grunt-task-loader:

require('grunt-task-loader')(grunt, {
  mapping: {
    express: 'grunt-express-server'
  }
});

You can also submit a PR to add this name mapping to the plugin defaults.

Package names that are simply prefixed with 'grunt-' or 'grunt-contrib-' are automatically handled, and so are mappings like ngAnnotate to grunt-ng-annotate, if convertCamelCase is true.

License

MIT