Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-env-compatible

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-env-compatible - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

dist/index.js

@@ -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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc