Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 464
Marcin Avatar asked Nov 10 '22 12:11

Marcin


1 Answers

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)
  ...
  ...
})
like image 147
madmxg Avatar answered Jan 04 '23 02:01

madmxg