Reputation: 2019
I have all of my paths defined at the top of the project,
var paths = {
scripts: ['./js/main.js', './js/datetimepicker.js'],
styles: ['./stylesheets/style.scss', './stylesheets/datetimepicker/datetimepicker.css', './stylesheets/vis/vis.css'],
images: ['img/**/*'],
libs: ['./js/*.min.js', './img/*', './fonts/FontAwesome/*'],
compress: ['./css/**', './fonts/FontAwesome/**', './img/**', './js/main.min.js', './js/bootstrap.min.js'],
concat: [{
'src': './web-src/js/services*.js',
'name': 'services.js'
}]
};
My issue is that when I call paths.concat[0].src
I am forced to specify what index in the array I want. So when I call my concat task,
gulp.task('concat', function () {
return gulp.src(paths.concat[0].src)
.pipe(concat(paths.concat[0].src))
.pipe(gulp.dest('./dist/'));
});
Having the paths defined is not helpful. What is the 'best practice' way of looping over a task?
Thanks
Upvotes: 1
Views: 1758
Reputation: 2019
I accomplished this using,
gulp.task('concat', function () {
return paths.concat.forEach(function(obj) {
return gulp.src(obj.src)
.pipe(concat(obj.name))
.pipe(rename(function (path) {
path.basename += '.min';
return path;
}))
.pipe(gulp.dest('./web/js'));
});
});
Upvotes: 2