This plugin is used to patch environment variables from the system into Vite
English | 简体中文
pnpm i -D vite-plugin-patch-env
// vite.config.ts
import { defineConfig } from "vite";
import PathEnv from "vite-plugin-patch-env";
export default defineConfig({
plugins: [PathEnv()],
});
> env
...
HOME=/Users/kejun
...
console.log(import.meta.env);
// output
// {
// //...
// VITE_HOME: "/Users/kejun"
// //...
// }
see example
export type EnvName = RegExp | string;
export interface Options {
names?: EnvName | EnvName[];
}
use names
to filter env, default patch all env