Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/IndexXuan/vite-plugin-env-compatible
Environment Variables Compatible for vite(with vue-cli, create-react-app and so on)
https://github.com/IndexXuan/vite-plugin-env-compatible
vite vite-plugin
Last synced: 2 months ago
JSON representation
Environment Variables Compatible for vite(with vue-cli, create-react-app and so on)
- Host: GitHub
- URL: https://github.com/IndexXuan/vite-plugin-env-compatible
- Owner: IndexXuan
- Created: 2021-02-18T06:37:39.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-01T12:15:16.000Z (about 1 year ago)
- Last Synced: 2024-04-23T12:18:04.954Z (9 months ago)
- Topics: vite, vite-plugin
- Language: TypeScript
- Homepage:
- Size: 98.6 KB
- Stars: 66
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vite-plugin-env-compatible
> inject to process.env like vue-cli or create-react-app and also define client `process.env.XXX` for you.
## Motivation
- `vite` expose env to `import.meta.env.PREFIX_XXX`, but not loaded to process.env like vue-cli or create-react-app.
- ~~this plugin support setting prefix like `VUE_APP_` or `REACT_APP_` and loaded to process.env~~(support by [email protected]).
- built-in with [vue-cli-plugin-vite](https://github.com/IndexXuan/vue-cli-plugin-vite) just for compatibility.## Usage
```sh
yarn add vite-plugin-env-compatible
``````ts
// vite.config.ts
import env from 'vite-plugin-env-compatible'// @see https://vitejs.dev/config/
export default defineConfig({
plugins: [
// ...other plugins
env(/* options */)
],
})
```## Options
- [@see](https://github.com/IndexXuan/vite-plugin-env-compatible/blob/main/src/lib/options.ts)## Underlying
- dotenv & dotenv-expand
- [vite](https://github.com/vitejs/vite/blob/27785f7fcc5b45987b5f0bf308137ddbdd9f79ea/packages/vite/src/node/config.ts#L791)## Further
- [vue-cli-plugin-vite](https://github.com/IndexXuan/vue-cli-plugin-vite)