feat(admin-bundler): forward env vars to plugin admin extensions (#13634)

* forward plugin envs

* mock process.env

* remove normalizedName

* strip prefix
This commit is contained in:
Leonardo Benini
2025-10-02 16:19:13 +02:00
committed by GitHub
parent 76aa4a48b3
commit ea3d0100a9
2 changed files with 14 additions and 0 deletions

View File

@@ -70,6 +70,15 @@ export async function getViteConfig(
],
}
// Inject plugin environment variables with vite define
const pluginEnv: Record<string, string | undefined> = { BACKEND_URL: backendUrl }
for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith("PLUGIN_")) {
pluginEnv[key.replace(/^PLUGIN_/, "")] = value
}
}
baseConfig.define!["process.env"] = JSON.stringify(pluginEnv)
if (options.vite) {
const customConfig = options.vite(baseConfig)
return mergeConfig(baseConfig, customConfig)