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

config-grunt-tasks

v1.0.3

Published

Grunt task configuration loader

Downloads

114

Readme

config-grunt-tasks

Grunt task configuration loader that helps organize your Gruntfile.js tasks configuration.

The idea is to modularize your tasks configurations to make your setup more approachable and easier to work with. So instead of having one ginormous Gruntfile.js, you break out all your tasks' configurations into separate files and put them in a common directory. You can then tell config-grunt-tasks about your directory so that it can load all these configurations for ya. I personally like to create a folder called tasks, which contains all the different configurations for each grunt task in separate JavaScript files. But config-grunt-tasks is flexible enough to let you customize how you slice your pie.

config-grunt-tasks goes really well with load-grunt-tasks.

Also, this article by Thomas Boyt is good literature on the topic.

Install

npm install --save-dev config-grunt-tasks

Picture this

Sample conversation

Conventions

config-grunt-tasks uses conventions for mapping task configurations to file names. That is to say that your eslint task will require a file called eslint.js in your tasks directory, where all your grunt tasks are stored. This eslint.js should export JSON to configure your eslint task, or a function that is called to get JSON your eslint settings.

When your task file exports a function, it will get called with the current instance of Grunt as the first argument.

Examples

Please see examples for an actual Gruntfile.js file and a folder with tasks. Otherwise, below you will get quick examples of what your gruntfiles might look like.

First,

let's look at a setup where config-grunt-tasks loads all the tasks in you tasks folder.

module.exports = function(grunt) {
  require("load-grunt-tasks")(grunt);

  var pkg = require("./package.json");
  var taskConfig = require("config-grunt-tasks")(grunt, "./tasks");
  taskConfig.pkg = pkg;

  grunt.initConfig(taskConfig);

  grunt.registerTask("build", ["eslint:all"]);
  grunt.registerTask("test", ["connect:test", "mocha:test"]);
};

Second,

let's look at a setup where config-grunt-tasks loads specific tasks. Some people like more control over their stuff! I am certainly not judging you. :)

module.exports = function(grunt) {
  require("load-grunt-tasks")(grunt);

  var pkg = require("./package.json");
  var taskConfig = require("config-grunt-tasks");

  grunt.initConfig({
    pkg: pkg,
    connect: taskConfig(grunt, "./tasks/connect.js").connect,
    mocha: taskConfig(grunt, "./tasks/mocha.js").mocha,
    watch: taskConfig(grunt, "./tasks/watch.js").watch,
    eslint: taskConfig(grunt, "./tasks/eslint.js").eslint,
    concurrent: taskConfig(grunt, "./tasks/concurrent.js").concurrent,
    uglify: taskConfig(grunt, "./tasks/uglify.js").uglify,
    release: taskConfig(grunt, "./tasks/release.js").release
  });

  grunt.registerTask("build", ["eslint:all"]);
  grunt.registerTask("test", ["connect:test", "mocha:test"]);
};

I have several of my projects where I use config-grunt-tasks. Time permitting, all my projects will get this treament. But here are some if you want to checkout how I use it.

License

Licensed under MIT