Is your feature request related to a problem? Please describe.
https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables
The .env file has the least precedence and should have its variables be overriddable by .local and environment-specific files. The build produced by running npx serverless with this component currently ignores all .env* files other than .env
I'm currently keeping my secrets for dev in .env.local. Before I want to deploy I copy the variables from .env.production.local (gitignored by nextjs by default) into .env and revert the change after the deployment is done. This is not the best experience.
Describe the solution you'd like
Environment variables should be be retrievable from other .env* files, not just .env.
Have a look at:
https://github.com/danielcondemarin/serverless-next.js/tree/master/packages/serverless-component/examples/multiple-instance-environment
It's not the same, but I am using this successfully, saving manual intervention. I do agree with your issue title for consistency.
@medv That works, but since the most recent release of NextJS (9.4) there is first class support for .env files with an opinionated approach (.env* vs .env*.local)
It would be nice for this library to include this feature as new NextJS developers who start using this library would expect the same behaviour.
Most helpful comment
@medv That works, but since the most recent release of NextJS (9.4) there is first class support for .env files with an opinionated approach (.env* vs .env*.local)
It would be nice for this library to include this feature as new NextJS developers who start using this library would expect the same behaviour.