Search icon CANCEL
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
Learning Grunt

You're reading from   Learning Grunt Monitor and automate complex JavaScript tasks and processes by obtaining a practical understanding of Grunt

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher Packt
ISBN-13 9781785888809
Length 184 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Douglas Reynolds Douglas Reynolds
Author Profile Icon Douglas Reynolds
Douglas Reynolds
Arrow right icon
View More author details
Toc

The default task configuration


Creating the default task is as simple as loading tasks. Grunt has a registerTask method that we use to name (alias) the task and provide a list of one or more tasks to be run. When the task alias is run, all of the associated tasks in its list are run. In this way we can create a single command that runs the task(s) in the associated list. Additionally, the order of the tasks in the list defines the order in which the tasks are run; this provides us with even more refined control.

The basic task configuration syntax is:

grunt.registerTask(task_name, task_list);

In order to define the default task, the task name given should be 'default'. This task will run all of the associated tasks in its list even if no tasks are specified. For example, in order to run the default task, all that is needed is to issue the grunt command in the command prompt. The list argument to the registerTask method is an array of tasks. This syntax looks like the following example:

grunt...
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