New cra support .env file as .env and .env.{NODE_ENV}銆侻any times need to use other custom environments such as .env.qa, .env.pre an so on. Would CRA consider supporting this feature in the after-process?
I suggest that we refer to vue-cli to support --mode option, and it should be optional. When the mode option is exist, it would be replace NODE_ENV variable to load the .env file as .env.{mode}.
In case you are looking for a workaround, in our project we use env-cmd:
"scripts": {
"start": "env-cmd -f .env.dev react-scripts start",
"build:prod": "env-cmd -f .env.prod react-scripts build",
"build:dev": "env-cmd -f .env.dev react-scripts build",
},
@PupoSDC Thanks, does it also merge with .env file?
I had your problem and I've used the env-cmd and the Result will be merged with .env file. But I agree with you to use something like --mode flag.
I also hope to support --mode flag.
Most helpful comment
In case you are looking for a workaround, in our project we use
env-cmd: