A simple plugin to modularize your Gruntfile by putting configuration options and tasks in a `grunt` subfolder.
Last updated 4 years ago by chriszarate .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install grunt-load-options 
SYNC missed versions from official npm registry.


Build Status NPM version

This Grunt plugin provides a very simple way to modularize your Gruntfile. Put plugin configuration options in grunt/config and tasks/aliases in grunt/tasks. Use JavaScript, CoffeeScript, or JSON.

In other words, stop fussing with your Gruntfile whenever you start a new project. Instead, just copy over the files you need. See this project’s Gruntfile and grunt folder for an example.

Getting Started

This plugin requires Grunt >=0.4.0.

npm install --save-dev grunt-load-options

Once the plugin has been installed, it can be enabled in your Gruntfile.js (or use load-grunt-tasks and skip this step):


Example usage

Use this plugin in conjunction with load-grunt-tasks for a nice, clean, static Gruntfile and easily portable Grunt options and tasks:

module.exports = function (grunt) {

That’s it! That’s your entire Gruntfile, forever, for every project. Behind the scenes, this plugin loads your plugin configuration and tasks from the grunt subfolder.

Plugin options

To configure a Grunt plugin, create a file in grunt/config or grunt/options (either works). The name of the file should correspond to the property of the configuration object we want to define. For example, if you want to configure grunt-contrib-jshint, create a file named jshint.js:

module.exports = {
  all: [
  options: {
    jshintrc: '.jshintrc'

Or just provide JSON! (Make sure to give your file a .json extension.)

  "all": [
  "options": {
    "jshintrc": ".jshintrc"

If you need access to the grunt object, wrap it in a function with grunt as a parameter and return your options object. Here’s pkg.js:

module.exports = function (grunt) {
  return grunt.file.readJSON('package.json');

You can also use CoffeeScript. (Make sure to give your file a .coffee extension.)

module.exports = (grunt) ->
  grunt.file.readJSON "package.json"

Tasks and aliases

To create a task or alias, create a file in grunt/tasks or grunt/aliases:

Every task needs access to the grunt object, so wrap it in a function with grunt as a parameter. No need to return anything, though.

module.exports = function (grunt) {
  grunt.registerTask('default', ['jshint']);

CoffeeScript works here, too:

module.exports = (grunt) ->
  console.log grunt.template.process "grunt-load-options v<%= pkg.version %>"

Custom folder

Point the plugin to a different folder using the optional options parameter.

module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt, {folder: '~/.grunt-options'});

Current Tags

  • 1.0.0                                ...           latest (4 years ago)

8 Versions

  • 1.0.0                                ...           4 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.4                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © |