Marcin
Marcin

Reputation: 821

How to pass parameters in gulp dependencies

I'd like to prepare a different versions of a software by passing a special parameters in gulp task.

I've created tasks for css, js, etc. and made one to run then all:

gulp.task('compile', ['css', 'twig', 'js', ....]);

How to pass a parameter which will be passed also to the subtasks? Is there any way to do that?

I'd like to run e.g.: gulp compile --mode A and gulp compile --mode B

Thank you in advance.

Upvotes: 5

Views: 1869

Answers (1)

madmxg
madmxg

Reputation: 359

For this, I'm use yargs module

in gulpfile use:

var mode = require("yargs").argv.mode;

run task with:

gulp compile -mode A

In your [css/twig/etc] tasks use:

gulp.task("css", function(){
  var cssSRC = "./src/" + mode + "/*.css";
  gulp.src(cssSRC)
  ...
  ...
})

Upvotes: 1

Related Questions