Gulp 4: Passthrough source streams
07 September 2015 by @ddprrt | Posted in: gulp, tools
Another nice addition to
vinyl-fs that will end up in Gulp 4 is the possibility
of having “passthrough” source streams. This basically allows
gulp.src to be
writable. So what does this mean for you?
gulp.src would create a stream of file objects based on the globbing
pattern you provide. This made
gulp.src mandatory to be at the beginning of
your stream. Now it can be anywhere in your pipeline, carrying over the intermediate
results from the earlier steps.
The process explained:
- Those are the files we create, which means we want to have them linted to our coding conventions
- After the JSHint process, we get all our vendor files.
Those include things like jQuery, lodash, you name it. By using the
passthroughflag, all the file objects from the original pipeline are passed through, and thus added to the whole stream.
We can also benefit from this feature when we want to merge preprocessor output with plain source files:
Same with CoffeeScript, if you are into that:
While this doesn’t solve all the scenarios where merging comes in handy, combining different sources mid-stream is definitely a welcomed addition.
Me again. The Gulp, Yeoman, Bower book is pretty sweet. Just saying.
Comments? Shoot me a tweet!