I have a gulpfile with constant PATH object. One of its fields is array. I want to iterate through it and assign different watch to react with different tasks. But when I try it assing task in loop:
for(var i = 0; i < PATH.PHP[i].MODULE.length; i++){
gulp.task('sync-'+PATH.PHP[i].MODULE, function(){
return gulp.src(PATH.PHP[i].IN)
.pipe(newer(PATH.PHP[i].OUT))
.pipe(gulp.dest(PATH.PHP[i].OUT));
});
}
PATH.PHP[i] is not defined within anonymous function. The reason I need it because if I watch whole folder it takes too much time syncing it with remote, if preprocessed through plugins like "gulp-newer" and "gulp-changed".