Automatically loading Grunt tasks with matchdep
Have you ever installed a new GruntJS-plugin and then forgotten to load it as a task in the gruntfile.js? Matchdep is a handy tool, which can solve this issue.
What is matchdep?
Matchdep is a tool which can filter node.js dependencies, which are in the
Installing it is very easy:
npm install --save matchdep
Automatically loading GruntJS tasks
What we are doing here is: basically reading all (dev)dependencies from the
package.json and filtering those out which begin with 'grunt-'. These are tasks like all Grunt contrib tasks (
grunt-contrib-copy, etc.) and other Grunt specific tasks (like
grunt-hashres). After filtering we load them as tasks.
matchdep be used for besides loading Grunt tasks?
Honestly I must say, I have no idea. But this is still pretty cool, that we don't have to include each grunt plugin individually.
by Adam Beres-Deak
Latest blog posts
Displaying icons with custom elements 14th October 2015
After the first year of blogging - what happened on my blog in 2014? 1st January 2015
Better webfont loading with using localStorage and providing WOFF2 support 18th December 2014