Chapter 7. Working with streams
This chapter covers
- Merge streams and passthrough streams for combining different sources
- Stream arrays for duplicating streams
- Stream combiners for creating stream snippets
- Stream queues for handling stream element order
- Stream filters for dynamically changing stream contents
Previously you created build pipelines for different types of assets, like CSS and JavaScript. Stylesheets and scripts are fundamentally different, so you had to treat them differently. That resulted in one build pipeline for each asset type, which you saw in chapter 2. But what if you have to handle files that are of the same type and require the same process but vary enough that you have to duplicate pipeline definitions?
Think back to our original script task from chapter 2. With this task, you built exactly one JavaScript bundle. All your sources were combined into one output file. What if you have to create more than one? Or even worse, what if you have to create bundles originating from different JavaScript preprocessor languages? CoffeeScript or TypeScript both compile to plain JavaScript. Those languages need a transformation step before the main task of concatenating and minifying can take place.