S
S
sanex33392015-08-24 13:37:04
gulp.js
sanex3339, 2015-08-24 13:37:04

Is there a plugin for passing parameters to tasks?

Is there a plugin for passing parameters to tasks in gulp.start?
For example:

gulp.task('projectOne', function(){
   gulp.start({
        'buildJS': {
            path: 'one/js/',
            var: 'test'
        }
    }, 'buildCSS'); 
});

gulp.task('projectTwo', function(){
   gulp.start({
       'buildJS': {
            path: 'two/js/',
            var: 'test'
        }
    }, 'buildCSS'); 
});

Well, accordingly, in buildJS it would be possible to get this path and var and, moreover, pass them to the next task (for example, we run the watch task with the 'path' parameter, and in the 'watch' task we pass this path also to the 'js' task .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sanex3339, 2015-08-24
@sanex3339

Found a solution

var modules = ['frontend', 'backend'];
var each = require('async-each');

var build = function (module, cb) {
  gulp.src('src/' + module + '.js')
    .pipe(browserify());
  cb();
};

gulp.task('build', function (cb) {
  each(modules, build, cb);
});

gulp.task('default', ['build'], function () {
  modules.forEach(function (module) {
    gulp.watch('src/' + module + '/**', function () {
      build(module, function () {});
    });
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question