Closed ajaybc closed 8 years ago
I feel like it might be gulpier to keep the JSON output here and use a transformer as the next step in the pipeline. Composition rather than configuration, and all :)
@bobthecow I thought like that at first. But the thing is that gulp-rev has this feature where it tries to read an existing manifest in JSON and tries to merge the current values on to it. If we put the transformer next in the pipeline, it wont be able to read that file as it might not be JSON depending on the transformer used. By specifying the transformer while calling the manifest function, we can avoid this problem. Also IMO the actual transformation logic is decoupled from the gulp-rev logic.
@ajaybc This is a good point. :+1:
This was never released on NPM 😿
I added an option to specify a custom transformer for the output rev file. For example if the user wants the output in YAML format instead of the default JSON format, he can specify like this
.pipe(rev.manifest('assets-manifest.yaml', {merge:true, transformer : require('yamljs')}))
The transformer can be any object which has a
parse
andstringify
function. Theyamljs
library in the above example already has those 2 functions, so it can be used directly. This way even if the user wants the manifest in some specific format like for example, PHP associative array, then he can write a transformer for that.