@liuli-util/vite-plugin-env-dts-gen
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@liuli-util/vite-plugin-env-dts-gen

中文

Scan environment variables to generate dts type definitions to avoid manually maintaining dts type definitions for environment variables.

use

pnpm i -D @liuli-util/vite-plugin-env-dts-gen

Configure the plugin

//vite.config.ts
import { defineConfig } from 'vite'
import { envDtsGen } from '@liuli-util/vite-plugin-env-dts-gen'

export default defineConfig({
  plugins: [envDtsGen()],
})

Example

FAQ

The default plugin has the following behavior

  • When the ImportMetaEnv interface in src/vite-env.d.ts already contains fields, it will not be repeatedly added or replaced, but skipped. This behavior is mainly to allow users to customize environment variables
  • never automatically clear an environment variable, even if it no longer exists in .env*, for the same reason as above
  • Forcibly generate an environment variable during build, even if there is no change, this behavior is to avoid building immediately after pulling the code for the first time

Readme

Keywords

none

Package Sidebar

Install

npm i @liuli-util/vite-plugin-env-dts-gen

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

37.1 kB

Total Files

20

Last publish

Collaborators

  • rxliuli