How do I use different config files for environment variables, ensuring that these files are distinct for development and production environments?

I’m currently developing a NestJS application and want to manage environment variables using different configuration files for development and production environments. I understand that it’s common practice to separate configurations to avoid accidentally exposing sensitive information or misconfiguring settings.

I would like to know the best approach to achieve this in a NestJS application. Specifically, I’m looking for guidance on:

How to create and structure separate configuration files (e.g., .env.development and .env.production).
How to load the appropriate configuration file based on the environment (e.g., using NODE_ENV).
Any recommended libraries or modules to facilitate this process (e.g., @nestjs/config).