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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access