View on GitHub

Grunt-generate-configs

Generate separate grunt configuration files automatically

Download this project as a .zip file Download this project as a tar.gz file

grunt-generate-configs GitHub versionBuild Status

CLI to generate separate grunt configuration files automatically

This command will take your big, fat grunt configuration object and automatically generate separate files to store the task configuration objects in. It's a one time operation to be done before you start using load-grunt-configs

Generates config files in following formats:

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-generate-configs -g

We install it globally, so you can reuse it for all your projects. Once the plugin has been installed, you can run it from the command line in the directory of your project:

generate_configs

The command will parse your grunt configuration object and automatically create files for each task.

Command line options

Examples

For example, if this is your grunt configuration inside Gruntfile.js:

grunt.initConfig({
    jshint   : {
        all     : [
            'Gruntfile.js', 'tasks/*.js', '<%=nodeunit.tests%>'
        ],
        options : {
            jshintrc : '.jshintrc',
        },
    },

    // Before generating any new files, remove any previously-created files.
    clean    : {
        config : ['config'],
    },

    // Unit tests.
    nodeunit : {
        tests : ['tests/*_test.js'],
    },
});

It will create the files jshint.json, clean.json and nodeunit.json inside a config directory, containing the configuration objects:

//file: config/jshint.json
{
  "all": [
    "Gruntfile.js",
    "tasks/*.js",
    "<%=nodeunit.tests%>"
  ],
  "options": {
    "jshintrc": ".jshintrc"
  }
}
//file: config/clean.json
{
  "config": [
    "config"
  ]
}
//file: config/nodeunit.json
{
  "tests": [
    "tests/*_test.js"
  ]
}

Once these files are generated, use the load-grunt-configs module to automatically load all configuration files:

npm install load-grunt-configs --save-dev

and inside your Gruntfile.js replace the grunt configuration object with:

var configs = require('load-grunt-configs')(grunt);
grunt.initConfig(configs);

See the project for more information, options and examples: load-grunt-configs

Example output

Changelog

v0.5.1

v0.5.0

v0.4.1

v0.4.0

v0.3.0

v0.2.0

v0.1.2

v0.1.1

v0.1.0

License

Copyright (c) 2014 Camille Reynders Licensed under the MIT license.

Analytics