Skip to content

Commit ea3d010

Browse files
authored
feat(admin-bundler): forward env vars to plugin admin extensions (#13634)
* forward plugin envs * mock process.env * remove normalizedName * strip prefix
1 parent 76aa4a4 commit ea3d010

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

.changeset/sharp-apples-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/admin-bundler": patch
3+
---
4+
5+
feat(admin-bundler): forward env vars to plugin admin extensions

packages/admin/admin-bundler/src/utils/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ export async function getViteConfig(
7070
],
7171
}
7272

73+
// Inject plugin environment variables with vite define
74+
const pluginEnv: Record<string, string | undefined> = { BACKEND_URL: backendUrl }
75+
for (const [key, value] of Object.entries(process.env)) {
76+
if (key.startsWith("PLUGIN_")) {
77+
pluginEnv[key.replace(/^PLUGIN_/, "")] = value
78+
}
79+
}
80+
baseConfig.define!["process.env"] = JSON.stringify(pluginEnv)
81+
7382
if (options.vite) {
7483
const customConfig = options.vite(baseConfig)
7584
return mergeConfig(baseConfig, customConfig)

0 commit comments

Comments
 (0)