Source: Is it possible to pass a flag to Gulp to have it run tasks in different ways?

Yargs

Gulp doesn’t offer any kind of util for that, but you can use one of the many command args parsers. I like yargs. Should be:

Combinaison de Yargs et de Gulp-if

You can also combine it with gulp-if to conditionally pipe the stream, very useful for dev vs. prod building:

And call with gulp my-js-task or gulp my-js-task --production.

Remarque: selon les cas, on peut vouloir n’exécuter une tâche que dans le cas ou l’argument --dev n’a pas été précisé. Il suffit de mettre un caractère ! (signifiant « différent de ») devant la condition:


Autre alternative (moins pratique, mais qui fonctionne aussi) : gulp-options.