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 Automatically Run Tasks with Gulp’s Watch Method

lihaoquan
lihaoquan
12,045 Points

Gulp task dependencies

Quote from this video :

"Really quick, I wanna point out here that I don't need to use a return statement. Without getting too detailed about it, just remember that if other tasks don't depend on a given task, you don't need to return anything from its callback."

If this is true, then why add return statement for "compileSass" task? Can't it run parallel with "minifyScripts" and "concatScripts" since it doesn't depend on any of them?

1 Answer

akak
akak
29,445 Points

I'm not a gulp expert, but I would say that gulp.watch depends on compileSass. If you don't provide a return from compileSass, the gulp.watch won't know if the task ended or not and will hang endlessly waiting for sass being compiled after first time it started. I can't check that theory right now, but seems like a good candidate :)

lihaoquan
lihaoquan
12,045 Points

Thanks for the suggested theory, however, I've tried "gulp watchFiles" without return statement for compileSass, it worked correctly, so I don't think that is the problem.