firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 915 forks source link

Allow dotenv files from different environments for SSR and SSG in Next.js #7323

Open chalosalvador opened 2 weeks ago

chalosalvador commented 2 weeks ago

Description

This PR is intended to fix the issue #7207 by checking if the .env. file exists and make it available for the build process.

Scenarios Tested

  1. Initialized a hosting project with Next.js
  2. Created a .env.<PROJECT-ID> file in the root of the Next.js project
  3. Created a page that uses SSR and accesses the environment variable in .env.<PROJECT-ID>
  4. Created a page that uses SSG and accesses the environment variable in .env.<PROJECT-ID>
  5. Deployed the project to Firebase hosting.
  6. Make sure the environment variable in the .env.<PROJECT-ID> is available in a server side rendered page.
  7. Make sure the environment variable in the .env.<PROJECT-ID> is available in a static generated page.

Sample Commands