/require-grunt-configs

Load a directory of grunt configurations.

Primary LanguageJavaScriptMIT LicenseMIT

require-grunt-configs

Build Status Build Status NPM version

Load a directory of grunt configurations. I wrote this because even a trivial grunt configuration can look a bit unwieldy as one huge file. Check out the before and after examples to understand the benefit.

Wait, What?

Keep your main Gruntfile clean by extracting configuration into individual files. The name of the file is the same as the task name. For example, the grunt jshint configuration would go into grunt/jshint.js while the grunt concat configuration would go into grunt/concat.js.

Check out these examples for a more in-depth look at how this works.

Installation

% npm install require-grunt-configs --save-dev

Configuration

By default, require-grunt-configs loads files from the grunt directory; however, you may prefer a more organized directory structure (as do I) such as the one below:

grunt
└── conf
    ├── concat.js
    └── jshint.js
    └── notify.js
    └── pkg.js
    └── sass.js
    └── uglify.js
    └── watch.js

In order to load the above configuration files, in your Gruntfile add:

require('require-grunt-configs')(grunt, 'grunt/conf')

Explore the directory grunt/conf to view the contents of the example configuration files listed above.

Examples

Inspiration

Alternatives

  • load-grunt-config: does a lot more than configuration.
  • grunt-configure: I wasn't comfortable with the LOC and dependency list given the task.
  • how @cowboy modularizes Gruntfiles: uses tasks for external config -- I will be exploring this approach for future projects.

License

MIT