Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Gulp Basics Improving your Gulp Task Pipelines Putting Multiple Tasks Together

Is there a way to elegantly make a serial flow?

So, let's say I have gulp tasks x,y, and z. x and y might not be explicitly related to each other, so creating ['y'] as a dependency in X feels super ugly to me.

If I want tasks, x,y, and z to run in THAT order, but don't want to explicitly make a relationship between the components... is there a way to do that?

1 Answer

Tom Geraghty
Tom Geraghty
24,174 Points

Do the first but not the second thing he does in the video. Add the return statements to x (gulp task concatScripts) and y (gulp task minifyScripts), but leave out the dependency changes in z (gulp task compileSass).

Since x and y depend on each other, the gulp task call for minifyScripts can be called and since minifyScripts has as a dependency concatScripts then concatScripts will have to return from it's function before the minifyScripts can move on to do it's thing.

That way you can be sure concatScripts is done before minifyScripts is run, while simultaneously (aka concurrently or in parallel) you can process the other gulp task of compileSass which does not depend on the first two x and y.