perf: loadEnv api also needs to load shared env variables prefixed with VITE_

This commit is contained in:
alex8088 2023-12-15 22:14:58 +08:00
parent 0c98f33573
commit a8f5182d25

View file

@ -39,13 +39,13 @@ export function toRelativePath(filename: string, importer: string): string {
/** /**
* Load `.env` files within the `envDir` (default: `process.cwd()`) . * Load `.env` files within the `envDir` (default: `process.cwd()`) .
* By default, only env variables prefixed with `MAIN_VITE_`, `PRELOAD_VITE_` and * By default, only env variables prefixed with `VITE_`, `MAIN_VITE_`, `PRELOAD_VITE_` and
* `RENDERER_VITE_` are loaded, unless `prefixes` is changed. * `RENDERER_VITE_` are loaded, unless `prefixes` is changed.
*/ */
export function loadEnv( export function loadEnv(
mode: string, mode: string,
envDir: string = process.cwd(), envDir: string = process.cwd(),
prefixes: string | string[] = ['MAIN_VITE_', 'PRELOAD_VITE_', 'RENDERER_VITE_'] prefixes: string | string[] = ['VITE_', 'MAIN_VITE_', 'PRELOAD_VITE_', 'RENDERER_VITE_']
): Record<string, string> { ): Record<string, string> {
return viteLoadEnv(mode, envDir, prefixes) return viteLoadEnv(mode, envDir, prefixes)
} }