Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro ignores vite.envPrefix only during production build #5827

Closed
1 task
JLarky opened this issue Jan 11, 2023 · 1 comment · Fixed by #5852
Closed
1 task

Astro ignores vite.envPrefix only during production build #5827

JLarky opened this issue Jan 11, 2023 · 1 comment · Fixed by #5852
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@JLarky
Copy link
Contributor

JLarky commented Jan 11, 2023

What version of astro are you using?

1.9.1

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

None

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

change your configuration to add vite.envPrefix:

export default defineConfig({vite: {
    envPrefix: 'VITE_',
}});

For both scripts PUBLIC_P=1 VITE_P=2 was set in environment, both those values are accessible during SSR, but only one of them is going to be ignored on client (depending on the way you run it).

Running npm run dev:
image
Running npm run build && npm run preview:
image

My explanation is that it seems like Astro is ignoring astro.vite configuration during builds, but uses it during dev

Link to Minimal Reproducible Example

https://github.com/JLarky/astro-env-prefix-bug

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

Thanks!

@matthewp matthewp added the - P3: minor bug An edge case that only affects very specific usage (priority) label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants