Load multiple grunt tasks using globbing patterns
Usually you would have to load each task one by one, which is unnecessarily cumbersome.
This module will read the devDependencies in your package.json and load the tasks that matches your patterns.
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-sizediff');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-styl');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-bower-requirejs');require('load-grunt-tasks')(grunt);Install with npm: npm install --save-dev load-grunt-tasks
// Gruntfile.js
module.exports = function (grunt) {
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
grunt.initConfig();
grunt.registerTask('default', []);
}By default grunt-* will be used as the globbing pattern.
You can optionally specify a pattern or an array of patterns:
require('load-grunt-tasks')(grunt, 'grunt-shell');require('load-grunt-tasks')(grunt, 'grunt-contrib-*');require('load-grunt-tasks')(grunt, ['grunt-contrib-*', 'grunt-shell']);You also have the option to specify the package.json as an object if it's not in the same folder as your Gruntfile:
require('load-grunt-tasks')(grunt, 'grunt-shell', require('../package'));MIT License • © Sindre Sorhus
