inject working only when I get variable src!
Opened this issue · 1 comments
I've been working injecting some files into html:
The next code does not inject anything..
return gulp.src(config.index)
.pipe(wiredep(wiredepOptions))
.pipe($.inject(gulp.src(config.js), { read: false })
.pipe(gulp.dest(config.clientDest)));
but I store src into a variable like this:
var g1 = gulp.src(config.index);
return g1.pipe(wiredep(wiredepOptions))
.pipe($.inject(gulp.src(config.js)))
.pipe(gulp.dest(config.clientDest));
it does inject properly.
I was following John Papa tutorial and everything was fine til this moment.
I've also been looking for information but nothing exactly like this.
I don't understand what's going on there, if someone can help it would be wonderful
Thank you!
There are more differences between the first code example and the second... Take a look at the parentheses they don't match in the way I think you intended in the first example (which probably is the reason for the code not working).
When indenting everything on parentheses you'll see the issue more clear:
Code snippet 1 reindented:
return gulp.src(config.index)
.pipe(
wiredep(wiredepOptions)
)
.pipe(
$.inject(
gulp.src(config.js),
{ read: false } // also notice that this options object should be passed to `gulp.src` and not this plugin
)
.pipe( // <- here's your problem, this is placed at the wrong level (compare with next snippet)
gulp.dest(config.clientDest)
)
);
Code snippet 2 reindented:
var g1 = gulp.src(config.index);
return g1.pipe(
wiredep(wiredepOptions)
)
.pipe(
$.inject(
gulp.src(config.js)
)
)
.pipe(
gulp.dest(config.clientDest)
);