iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🎉
How to use .env.staging in Next.js
About
I want to ensure that .env.staging is loaded correctly.
Current Situation
As of 2021-02-12, you can define three files—.env, .env.development, and .env.production—along with .env.*.local.
Since staging is not a default, I want to define .env.staging instead of just using .env.
Discussion
It seems the official team does not have a policy to support this yet.
What to do
Installing env-cmd and specifying the file seems to be the better solution.
"build:staging": "env-cmd -f .env.staging yarn build && yarn start"
In fact, this correctly loaded .env.staging and .env.production respectively!
Discussion