Next.js sets process.env.NODE_ENV depending on the build environment. You could potentially also set another environment variable in your package.json like this:
"dev": "CONFG_ENV=development next",
"build": "CONFG_ENV=production next build",
"start": "CONFG_ENV=production next start",
Then in your next.config.js you'd refernece CONFIG_ENV instead of NODE_ENV.
Haha, there aren't actually any secrets in that folder 😁 I just always have a folder with that name that I gitignore and put things I don't want in the repo in there (config, actual secrets, etc). Totally slipped my mind it was named that here.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It only works for one environment, what about if you have other environments such .env.development .env.staging .env.production etc
did you found the answer?
take a look at dotenv-flow
I did something like this in
next.config.js
:Next.js sets process.env.NODE_ENV depending on the build environment. You could potentially also set another environment variable in your
package.json
like this:Then in your
next.config.js
you'd referneceCONFIG_ENV
instead ofNODE_ENV
.hopefully you weren't following the solution above and passing your application secrets into
DefinePlugin
...Haha, there aren't actually any secrets in that folder 😁 I just always have a folder with that name that I gitignore and put things I don't want in the repo in there (config, actual secrets, etc). Totally slipped my mind it was named that here.