Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Getting Started with Grunt: The JavaScript Task Runner
  • Table Of Contents Toc
  • Feedback & Rating feedback
Getting Started with Grunt: The JavaScript Task Runner

Getting Started with Grunt: The JavaScript Task Runner

By : Jaime Pillora, Bocoup LLC
4.4 (10)
close
close
Getting Started with Grunt: The JavaScript Task Runner

Getting Started with Grunt: The JavaScript Task Runner

4.4 (10)
By: Jaime Pillora, Bocoup LLC

Overview of this book

Table of Contents (12 chapters)
close
close

External tasks


In many instances, our Gruntfile.js file can become quite large and complicated, especially when we start including our own custom tasks into the mix. Grunt provides the means to split our custom tasks into their own individual files, thereby reducing the complexity of our Gruntfile.js and increasing reusability, since this new task file could also be used in other Grunt projects. In Chapter 3, Using Grunt, we learnt how to use grunt.registerTask to create our own custom tasks; however, to move these calls to registerTask into another file, we will need a reference to the grunt object (since grunt is passed into our Gruntfile.js).

This is exactly what the grunt.loadTasks function does: it is called with a directory path as the argument, then runs every JavaScript file inside the given directory as if it were a "mini" Gruntfile.js file (also passing it the current grunt object). The following example demonstrates this:

//Code example 02-external-tasks
// Gruntfile.js
module.exports...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Getting Started with Grunt: The JavaScript Task Runner
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon