I have an array of objects that looks like the following.
var bundles = [
{
src: 'js/my-ponent/*.js',
bundleName: 'my-ponent.js'
},
{
src: 'js/my-other-ponent/*.js',
bundleName: 'my-other-ponent.js'
}
]
I want the gulp task to process/concat every entry in the array, but it doesn't seem to work.
gulp.task('bundlejs', function(){
return bundles.forEach(function(obj){
return gulp.src(obj.src)
.pipe(concat(obj.bundleName))
.pipe(gulp.dest('js/_bundles'))
});
});
I have an array of objects that looks like the following.
var bundles = [
{
src: 'js/my-ponent/*.js',
bundleName: 'my-ponent.js'
},
{
src: 'js/my-other-ponent/*.js',
bundleName: 'my-other-ponent.js'
}
]
I want the gulp task to process/concat every entry in the array, but it doesn't seem to work.
gulp.task('bundlejs', function(){
return bundles.forEach(function(obj){
return gulp.src(obj.src)
.pipe(concat(obj.bundleName))
.pipe(gulp.dest('js/_bundles'))
});
});
Share
Improve this question
edited Aug 17, 2015 at 9:03
gkiely
asked Aug 17, 2015 at 8:58
gkielygkiely
3,0071 gold badge25 silver badges37 bronze badges
0
2 Answers
Reset to default 13You should probably be merging the streams and returning the result, so that the task will plete at the appropriate time:
var es = require('event-stream');
gulp.task('bundlejs', function () {
return es.merge(bundles.map(function (obj) {
return gulp.src(obj.src)
.pipe(concat(obj.bundleName))
.pipe(gulp.dest('js/_bundles'));
}));
});
This solution does work, I had the wrong directory name. Doh.
https://github./adamayres/gulp-filelog helped me find the problem.