Skip to content

ccit-spence/load-grunt-config

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#load-grunt-config

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".

##Features

  • 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).

##Installation

npm install -D load-grunt-config

##Example

Basic Gruntfile.js

module.exports = function(grunt) {

	require('load-grunt-config')(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
		config: { //additional config vars
			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 %>',
      'grunt/*.yaml'
    ],
    tasks: [
      'default'
    ]
  }
};

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

module.exports = function (grunt) {
  return {
    all: [
      'Gruntfile.js',
      'grunt/*.js',
      'lib/*.js',
      'test/*.js'
    ]
  };
};

Example yaml file - grunt/notify.yaml

default:
  options:
    message: 'Default finished'

Example coffee file - grunt/task.coffee

module.exports =
  options:
    bare: true

###Aliases

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']);).

grunt/aliases.yaml

default:
	- 'jshint'
	- 'mocha'
	- 'notify'

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published