John Lindquist
InstructorJohn Lindquist

Share this video with your friends

Send Tweet
Published 9 years ago
Updated 4 years ago

Grunt Multitask allows you to write complex tasks that run multiple targets. In this lesson, John will show you how to use Multitask in your GruntJS builds.

John Lindquist: Registering multitasks allows you to either iterate through or choose just an individual task to run from a list.

I say, "grunt.registerMultiTask." Say "tasks" is the name of it. Then, in here, I will "grunt.log.writeln("

That'll just be the name of the task. We configure something called "tasks" here, and we just have "one" and nothing.

Then we come down to the terminal, and we run grunt tasks. You can see that it logs out "one," because that is the name of that first task.

If we add "two" to this, I can run grunt tasks. You can see it runs "one," then "two."

I can also just run grunt tasks and target "one," and that'll only run "one," or "grunt tasks:two," and that will only run "two."

You can basically get the target and the data. We can say "target" plus some empty space plus ""

In here, we want the data to be "first" and the data to be "second." Then we'll just add a third one for good measure, or "three" and "third."

If I go "grunt tasks," you can see it runs "one" first, "two" second, "three" third. Then I can run any of them that I want. "Tasks:three," and it'll run "three" third.

Basically, you're taking this task you wrote. You can pass in any of the data, "one, two, three," into your task, use the target and data to run this however you want.