I'm trying to dynamically create tasks (minify and concat) based on jsFiles object. The key will give the destination file name and the array contains the src files. When I run gulp I see all the tasks names being ran but it only writes the last key which is group2.js in this case. What's wrong here?
// imports here
var jsFiles =
{
group1:[file1.js,file2.js],
group2:[file2.js,file3.js]
};
for (var key in jsFiles)
{
gulp.task(key, function() {
return gulp.src(jsFiles[key])
.pipe(jshint())
.pipe(uglify())
.pipe(concat(key + '.js')) // <- HERE
.pipe(gulp.dest('public/js'));
});
}
var defaultTasks = [];
for (var key in jsFiles)
{
defaultTasks.push(key);
}
gulp.task('default', defaultTasks);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…