Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with Grunt: The JavaScript Task Runner

You're reading from   Getting Started with Grunt: The JavaScript Task Runner If you know JavaScript you ought to know Grunt – the Task Runner for managing sophisticated web applications. From a basic understanding to constructing your own advanced Grunt tasks, this tutorial has it all covered.

Arrow left icon
Product type Paperback
Published in Feb 2014
Publisher
ISBN-13 9781783980628
Length 132 pages
Edition Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Jaime Pillora Jaime Pillora
Author Profile Icon Jaime Pillora
Jaime Pillora
Bocoup LLC Bocoup LLC
Author Profile Icon Bocoup LLC
Bocoup LLC
Arrow right icon
View More author details
Toc

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 example 03-load-plugin
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadTasks("./node_modules/grunt-contrib-copy/tasks");

Now, with this in mind, if we want to create and share our own tasks, we can publish them as a plugin. All we need to do is:

  1. Write...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime