jack e1a2621c78 update | 2 年之前 | |
---|---|---|
.. | ||
index.js | 2 年之前 | |
license | 2 年之前 | |
package.json | 2 年之前 | |
readme.md | 2 年之前 |
Load multiple grunt tasks using globbing patterns
🔥 Want to strengthen your core JavaScript skills and master ES6?
I would personally recommend this awesome ES6 course by Wes Bos.
Usually you would have to load each task one by one, which is unnecessarily cumbersome.
This module will read the dependencies
/devDependencies
/peerDependencies
/optionalDependencies
in your package.json and load grunt tasks that match the provided 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);
$ npm install --save-dev load-grunt-tasks
// Gruntfile.js
module.exports = grunt => {
// load all grunt tasks matching the ['grunt-*', '@*/grunt-*'] patterns
require('load-grunt-tasks')(grunt);
grunt.initConfig({});
grunt.registerTask('default', []);
};
require('load-grunt-tasks')(grunt);
Equivalent to:
require('load-grunt-tasks')(grunt, {pattern: ['grunt-*', '@*/grunt-*']});
require('load-grunt-tasks')(grunt, {pattern: 'grunt-contrib-*'});
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', 'grunt-shell']});
You can exclude tasks using the negate !
globbing pattern:
require('load-grunt-tasks')(grunt, {pattern: ['grunt-contrib-*', '!grunt-contrib-coffee']});
require('load-grunt-tasks')(grunt, {config: '../package'});
devDependencies
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
devDependencies
and dependencies
require('load-grunt-tasks')(grunt, {scope: ['devDependencies', 'dependencies']});
require('load-grunt-tasks')(grunt, {
pattern: 'grunt-contrib-*',
config: '../package.json',
scope: 'devDependencies',
requireResolution: true
});
Type: string
, array
Default: ['grunt-*', '@*/grunt-*']
(globbing pattern)
Type: string
, object
Default: Path to nearest package.json
Type: string
, array
Default: ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
Values: 'dependencies'
, 'devDependencies'
, 'peerDependencies'
, 'optionalDependencies'
, 'bundledDependencies'
Type: boolean
Default: false
Traverse up the file hierarchy looking for dependencies like require()
, rather than the default grunt-like behavior of loading tasks only in the immediate node_modules
directory.
MIT © Sindre Sorhus