Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 15 days 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-10T17:52:46.000Z (about 1 month ago)
- Last Synced: 2024-10-13T13:34:17.418Z (28 days ago)
- Topics: environment, vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 94.7 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
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