O'Reilly logo

Getting Started with Grunt: The JavaScript Task Runner by Jaime Pillora

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Grunt plugins

With the concepts from the section above, it becomes easy to understand how Grunt plugins work. Grunt plugins are just normal Node.js modules (that is, any directory with a package.json file), with the addition that they contain a tasks directory with JavaScript files to load. As we have seen throughout this book, when we wish to load the tasks provided by a Grunt plugin, we call the grunt.loadNpmTasks function with the name of the module. This loadNpmTasks function is very similar to the loadTasks function described previously, however, instead of using a directory to find JavaScript files, it uses the name of a module and then looks inside that module for a tasks folder. Therefore, the following two lines are equivalent:

//Code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required