https://github.com/KeJunMao/vite-plugin-patch-env
patch environment variables from the system into Vite
https://github.com/KeJunMao/vite-plugin-patch-env
environment vite vite-plugin
Last synced: 7 months ago
JSON representation
patch environment variables from the system into Vite
- Host: GitHub
- URL: https://github.com/KeJunMao/vite-plugin-patch-env
- Owner: KeJunMao
- Created: 2022-10-10T13:48:11.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-26T03:30:45.000Z (8 months ago)
- Last Synced: 2025-03-01T21:34:17.847Z (7 months ago)
- Topics: environment, vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 77.1 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vite-plugin-patch-env
> This plugin is used to patch environment variables from the system into Vite
English | [简体中文](./README.zh-CN.md)
## Installation
```
pnpm i -D vite-plugin-patch-env
```## Usage
```ts
// vite.config.ts
import { defineConfig } from "vite";
import PathEnv from "vite-plugin-patch-env";export default defineConfig({
plugins: [PathEnv()],
});
``````bash
> env
...
HOME=/Users/kejun
...
``````ts
console.log(import.meta.env);
// output
// {
// //...
// VITE_HOME: "/Users/kejun"
// //...
// }
```see [example](./examples/)
## Options
```ts
export type EnvName = RegExp | string;export interface Options {
names?: EnvName | EnvName[];
}
```use `names` to filter env, default patch all env