astro icon indicating copy to clipboard operation
astro copied to clipboard

🐛 BUG: vite.envDir is ignored when building

Open nrgnrg opened this issue 2 years ago • 2 comments

What version of astro are you using?

^1.0.0-beta.47

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm, npm

What operating system are you using?

Mac

Describe the Bug

When building a project the vite.envDir is ignored, it works as expected using the dev server.

in the stackblitz repro

  • check npm run dev -> it works, env printed to console and UI
  • check npm run build && npm run preview and all vars are undefined
  • move .env.local to same folder as astro.config.mjs
  • check npm run build && npm run preview and it works

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-tcuzrc-mzkyt7?on=stackblitz

Participation

  • [ ] I am willing to submit a pull request for this issue.

nrgnrg avatar Jun 20 '22 10:06 nrgnrg

Thanks for the simple repro @nrgnrg! Can confirm this occurs without the .local extension as well.

bholmesdev avatar Jun 20 '22 19:06 bholmesdev

Bumping up priority on anything that is a difference between dev and build!

FredKSchott avatar Aug 03 '22 18:08 FredKSchott

Hello. I cannot reproduce this issue in the latest version of Astro. I suspect this was fixed by https://github.com/withastro/astro/pull/4344

Thank you for reporting this issue! If this rehappen to you, please open another issue and we'll take a look!

Princesseuh avatar Sep 08 '22 19:09 Princesseuh