vite-plugin-env-compatible
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -200,3 +200,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __create = Object.create; | ||
return { | ||
name: "zone:env-compatible", | ||
name: "env-compatible", | ||
enforce: "pre", | ||
@@ -203,0 +203,0 @@ config(config) { |
{ | ||
"name": "vite-plugin-env-compatible", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Environment Variables Compatible", | ||
@@ -35,2 +35,6 @@ "main": "dist/index.js", | ||
"vite": "2.0.1", | ||
"@commitlint/cli": "7.2.0", | ||
"@commitlint/config-conventional": "7.1.2", | ||
"commitizen": "2.10.1", | ||
"cz-customizable": "5.2.0", | ||
"yorkie": "2.0.0" | ||
@@ -37,0 +41,0 @@ }, |
@@ -1,13 +0,30 @@ | ||
# @nibfe/vite-plugin-env-compatible | ||
# vite-plugin-env-compatible | ||
> 为 Vite 项目增加类似 Vue CLI 的环境变量注入模式 | ||
> inject to process.env like vue-cli or create-react-app | ||
## 用法 | ||
- 执行 `yarn add @nibfe/vite-plugin-env-compatible` | ||
## Motivation | ||
- `vite` expose `VITE_XXX` to `import.meta.env.VITE_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 | ||
- just for compatibility | ||
## 技术选型 | ||
## Usage | ||
```sh | ||
yarn add @nibfe/vite-plugin-env-compatible | ||
``` | ||
```ts | ||
// vite.config.ts | ||
import envCompatible from 'vite-plugin-env-compatible' | ||
// @see https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
// ...other plugins | ||
envCompatible() | ||
], | ||
}) | ||
``` | ||
## Underlying | ||
- dotenv & dotenv-expand | ||
## 说明 | ||
- `vite` 官方的环境变量相关功能其实已经基于 `dotenv` & `dotenv-expand` 做了,但是默认仅将 `VITE_` 开头的环境变量注入 client 代码,且采用最新的 es module 的 `import.meta.env` 来挂载 | ||
- 本插件支持设置要注入的环境变量前缀(默认 `VUE_APP_` 来兼容 vue-cli,用户可以设置为任意的,例如 `REACT_APP_` 等),且注入到 `process.env` 上 | ||
- [vite](https://github.com/vitejs/vite/blob/27785f7fcc5b45987b5f0bf308137ddbdd9f79ea/packages/vite/src/node/config.ts#L791) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10911
31
13