From e4a5f20a15a66ba27cb6b8b2fe8c25488f7d92ee Mon Sep 17 00:00:00 2001 From: "K.Adam White" Date: Tue, 6 Aug 2013 18:06:46 -0400 Subject: [PATCH] Use Matchdep module to load installed Grunt plugins Calling `loadNpmTasks` for each Grunt plugin installed is duplicative, so Tyler Kellen created a matchdep package to allow Grunt to piggyback on the list of Grunt plugins saved in package.json. Using this module reduces boilerplate and makes it more obvious the package.json is the canonical list of installed plugins. Tyler's a Grunt team member and Ben's endorsed the syntax, so it's an officially-sanctioned approach. --- Gruntfile.js | 10 +++------- package.json | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 24218fe..ac268a6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,6 +4,9 @@ module.exports = function(grunt) { var SOURCE_DIR = 'src/'; var BUILD_DIR = 'build/'; + // Load all the Grunt tasks listed in package.json + require('matchdep').filterDev('grunt-*').forEach( grunt.loadNpmTasks ); + // Project configuration. grunt.initConfig({ clean: { @@ -106,13 +109,6 @@ module.exports = function(grunt) { } }); - // Load tasks. - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-watch'); - // Register tasks. grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core', 'uglify:core', 'uglify:tinymce']); diff --git a/package.json b/package.json index b12e46f..de70f71 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "license": "GPLv2 or later", "devDependencies": { "grunt": "~0.4.1", + "matchdep": "~0.1.2", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-cssmin": "~0.6.1",