Skip to content

Commit 3a00ecb

Browse files
Rishi Raj Jainnatemoo-re
andauthored
Support envPrefix in Astro config (#5852)
* Support envPrefix in Astro config * Update packages/astro/src/core/config/schema.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update packages/astro/src/core/build/static-build.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update packages/astro/src/core/build/static-build.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update packages/astro/src/core/config/schema.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update packages/astro/src/core/create-vite.ts Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> * Update .changeset/twenty-llamas-type.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
1 parent ca22a81 commit 3a00ecb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/twenty-llamas-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Respect `vite.envPrefix` if provided

packages/astro/src/core/build/static-build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
161161
// SSR needs to be last
162162
ssr && vitePluginSSR(internals, settings.adapter!),
163163
],
164-
envPrefix: 'PUBLIC_',
164+
envPrefix: viteConfig.envPrefix ?? 'PUBLIC_',
165165
base: settings.config.base,
166166
};
167167

@@ -230,7 +230,7 @@ async function clientBuild(
230230
}),
231231
...(viteConfig.plugins || []),
232232
],
233-
envPrefix: 'PUBLIC_',
233+
envPrefix: viteConfig.envPrefix ?? 'PUBLIC_',
234234
base: settings.config.base,
235235
};
236236

packages/astro/src/core/create-vite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export async function createVite(
110110
],
111111
publicDir: fileURLToPath(settings.config.publicDir),
112112
root: fileURLToPath(settings.config.root),
113-
envPrefix: 'PUBLIC_',
113+
envPrefix: settings.config.vite?.envPrefix ?? 'PUBLIC_',
114114
define: {
115115
'import.meta.env.SITE': settings.config.site
116116
? JSON.stringify(settings.config.site)

0 commit comments

Comments
 (0)