How do I process one src file multiple ways using gulp? -


i want use 1 source file generate multiple destination files different characteristics. here's watered down version of want do:

gulp.task('build', function() {   var src = gulp.src('myfile.txt')    (var = 0; < 10; i++) {     src       .pipe(someplugin(i))       .pipe(rename('myfile-' + + '.txt'))       .dest('./build')   } }); 

presumably, "someplugin" change file contents based on index passed it, code above generate 10 files, each different content.

this doesn't work, , didn't expect to, there way achieve this?

i ended creating function builds tasks me. here's example:

function taskbuilder(i) {   return function() {     gulp.src('*.mustache')       .pipe(someplugin(i))       .pipe(rename('myfile-' + + '.txt'))       .dest('./build');   }; }  var tasks, task, i; (i = 0; < 10; i++) {   taskname = 'tasks-' + i;   gulp.task(taskname, taskbuilder(i));   tasks.push(task); }  gulp.task('default', tasks); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -