lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

🐛 BUG: `import.meta.env` variables missing

Open austin-raey opened this issue 3 years ago • 3 comments

What version of astro are you using?

1.0.0-beta.65

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

None

What package manager are you using?

yarn

What operating system are you using?

Mac 12.4

Describe the Bug

When attempting to use import.meta.env.PROD mentioned here, I'll get an error saying this PROD doesn't exist on undefined. In fact, it seems even import.meta` is undefined.

I've recreated this on the linked stackblitz.

Perhaps I'm missing something though? :) Thanks for the help!

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gm8tmg-wgv8zg?file=astro.config.ts

Participation

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

austin-raey avatar Jul 12 '22 00:07 austin-raey

Hi @austin-meadows!

import.meta.env is not available yet in astro.config.ts — it is only created after your config has been loaded. (We should probably add a note to this effect to the docs page.)

Some environment variables are available in config files using process.env but I suspect because this one is set by Astro, it won't be yet.

delucis avatar Jul 12 '22 06:07 delucis

This should be fixed by https://github.com/withastro/astro/pull/3617, which I still need to wrap up

natemoo-re avatar Jul 12 '22 16:07 natemoo-re

@delucis Ah okay, I understand! :) I must've gotten this impression from Vite, or I'm just misremembering entirely. 😂

@natemoo-re And that's awesome, thanks!!

austin-raey avatar Jul 12 '22 18:07 austin-raey