inject contents rather than filename
jmls opened this issue · 1 comments
jmls commented
is it possible to use gulp-inject to insert the contents of the source files into target, rather than just the name of the source file ?
return target.pipe($.inject(sources,{
starttag: '/* inject */',
endtag: '/* endinject */',
transform: (filepath, file, i, length) => {
return file.toString('utf8');
}
}))
I thought I'd try and be smart and return the file contents via a custom transform, but I end up with this in the target file
/* inject */
[object Object]
/* endinject */
I wanted to use gulp-inject because I want to keep the start and end tags, and insert contents between, rather than gulp-replace
If gulp-inject can't handle this, does anyone know of another gulp lib that may work this way ?
joakimbeng commented
You were so close!
There's a guide in the readme on how to inject the contents of a file.
You are seing the [object Object]
because the file
variable is a Vinyl file object, so you'll have to use the contents
property.