lazy-load-grunt-config

0.1.1 • Public • Published

lazy-load-grunt-config NPM Version

lazy-load-grunt-config is a Grunt library that allows you to break up your Gruntfile config by task. It was inspired by load-grunt-config

Installing

npm install lazy-load-grunt-config

Features

  • Each task has its own config file. Example: copy.js, uglify.js, etc.
  • Auto load all grunt plugins. Uses load-grunt-tasks.
  • Support for returning a function.
  • Easily register task aliases with aliases.js

API

Basic

module.exports = function(grunt) {
    require('lazy-load-grunt-config')(grunt);
};

With options

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

Aliases

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

grunt/aliases.js returning an object.

module.exports = {
    'default': [],
    css: ['copy', 'stylus']
};

grunt/aliases.js returning a function. Useful if there is need to compute something before return.

module.exports = function (grunt, options) {
    
    // Computation example:
    // --------------------
 
    var css = ['copy', 'stylus'];
    if (grunt.option('notify', false)) {
        css.push('notify:css');
    }
 
    return {
        'default': [],
        css: css
    };
};

Change log

0.1.0 / 2015-10-28

  • Initial commit

Readme

Keywords

Package Sidebar

Install

npm i lazy-load-grunt-config

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • comodinx