Grunt plugin that lets you break up your Gruntfile config by task

npm install load-grunt-config
207 downloads in the last day
3 515 downloads in the last week
11 894 downloads in the last month


load-grunt-config is a Grunt library that allows you to break up your Gruntfile config by task. For most small projects a single Gruntfile.js is perfect. But as a project grows, the Gruntfile.js can quickly become unmanagable; this is where load-grunt-config comes in handy. It was heavily inspired by Thomas Boyt's "More Maintainable Gruntfiles".


  • Each task has its own config file. Example: jshint.js, mocha.js, etc.
  • Auto load all grunt plugins. Uses load-grunt-tasks.
  • Auto expose package.json (<%= package.name %>).
  • Support for YAML files.
  • Support for coffeescript files.
  • Support for returning a function.
  • Easily register task aliases with aliases.(js|yaml|coffee).


npm install -D load-grunt-config


Basic Gruntfile.js

module.exports = function(grunt) {



Gruntfile.js with options

module.exports = function(grunt) {

    require('load-grunt-config')(grunt, {
        configPath: path.join(process.cwd(), 'grunt'), //path to task.js files, defaults to grunt dir
        init: true, //auto grunt.initConfig
        data: { //data passed into config.  Can use with <%= test %>
            test: false
        loadGruntTasks: { //can optionally pass options to load-grunt-tasks.  If you set to false, it will disable auto loading tasks.
            pattern: 'grunt-*',
            config: require('./package.json'),
            scope: 'devDependencies'


Grunt tasks files

Here's what the files in your grunt/ folder could look like. You can use either .js, .yaml, or .coffee - whatever you prefer and you can mix and match as you see fit.

Example js file returning an object - grunt/watch.js

module.exports = {
  all: {
    files: [
      '<%= jshint.all %>',
    tasks: [

Example js file returning a function - grunt/jshint.js

module.exports = function (grunt, options) {
  return {
    all: [

Example yaml file - grunt/notify.yaml

    message: 'Default finished'

Example coffee file - grunt/task.coffee

module.exports =
    bare: true


If your grunt/ folder contains an aliases.(js|yaml|coffee) file, load-grunt-config will use that to define your tasks aliases (like grunt.registerTask('default', ['jshint']);).


  - 'jshint'
  - 'mocha'
  - 'notify'

Custom Config

There are certain scenarios where you might have a base config for your team, and you want to be able to override some of the config based on your personal setup. You can do that with the overridePath property. In this case, the library will merge the two, with the override path taking priority. For example:

module.exports = function(grunt) {

  require('load-grunt-config')(grunt, {
    configPath: path.join(process.cwd(), 'vendor'),
    overridePath: path.join(process.cwd(), 'config-'+process.env.USER)

npm loves you