I don't want type the extra arguments NODE_ENV='production' gulp
every time I run gulp to set an environment variable.
I would rather set the environment variable from within gulp via a task.
What would be a good way to achieve this?
I don't want type the extra arguments NODE_ENV='production' gulp
every time I run gulp to set an environment variable.
I would rather set the environment variable from within gulp via a task.
What would be a good way to achieve this?
Try gulp-env
Quick example on how to set some environment variables before running the nodemon task:
You can also set one by default, and read the variables from a
json
file:This would be always
dev
env by default, and you could call it setting another env, like this:gulp --env prod
More of gulp-env
You can Setup the environment like follows:
Then you can use the environment to process the code as follows:
Use it like:
You can also define it as a script in your
package.json
And run it with
npm run gulp-build
. This has a few benefits