stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.94k stars 174 forks source link

Dotfiles missing in Stackblitz projects initialized from GitHub #1545

Open donmccurdy opened 1 month ago

donmccurdy commented 1 month ago

Describe the bug

Previously, I believe that initializing a new Stackblitz project from a URL ...

https://stackblitz.com/github/<user>/<repo>

... would include .env files, if they were checked into the repository (not in .gitignore). Testing some older examples now, that no longer works, and .env files are missing from the initialized Stackblitz project, causes startup to fail. For easier reproduction, I've created a minimal repository here:

https://github.com/donmccurdy/20241010-stackblitz-dotfiles

Link to the blitz that caused the error

https://stackblitz.com/github/donmccurdy/20241010-stackblitz-dotfiles

Steps to reproduce

  1. Go to https://stackblitz.com/github/donmccurdy/20241010-stackblitz-dotfiles
  2. Wait for output to the Stackblitz terminal
  3. Observe that env loads, but .env is missing

Expected behavior

  1. .env.local SHOULD be missing — it is in .gitignore and was never pushed to GitHub
  2. .env SHOULD NOT be missing — it is in version control, and is visible on GitHub

Parity with Local

Screenshots

Output:

Unable to read path ".env" [ENOENT: no such file or directory...
Unable to read path ".env.local" [ENOENT: no such file or directory...
{ env: 'OK=1' }

Platform

n/a

Additional context

I've filed an issue for the same problem at https://github.com/stackblitz/core/issues/3125, not sure which location is preferred in this case. Thanks!

abenrob commented 5 days ago

Hey folks! Is there any movement on this topic? I'm building with vite and react, and the ability to import env variables via import.meta.env.VITE_MY_ENV_VAR is required to provide a comparable experience between Stackblitz and the cloned repo. Is this a topic that is going to be touched?