Annotate vinyl stream in Gulp with additional metadata

What's the correct approach to writing a Gulp plugin that can annotate a stream with additional metadata that is then used later in the pipeline?

For example, the resizer plugin can take an array of dimensions as parameters to create [32,64,128]

. Then he could give each file transferred to (A, B, ...)

it several times, once for each image size specified in the settings: A+{s:32}, A+{s:64}, A+{s:128}, B+{s:32}, B+{s:64}, B+{s:128}

. A later Gulp plugin will see this metadata and resize the image accordingly.

The Vinyl object File

doesn't seem to support additional metadata, so how is it done to achieve this kind of processing with Gulp?

+3


source to share


1 answer


AFAIK you can add custom properties to the vinyl file and they will be preserved. For example gulp-sourcemaps depends on this.

The docs for the vinyl clone say "Returns a new File object with all the cloned attributes. The custom attributes are deeply cloned."



https://github.com/wearefractal/vinyl#clone

+4


source







All Articles