A plugin for Vite to auto-genarate d.ts delcaration file from .env* files
npm
npm i -D vite-plugin-env-dts
yarn
yarn add --dev vite-plugin-env-dts
pnpm
pnpm i -D vite-plugin-env-dts
// vite.config.{ts,js}
import EnvDTS from 'vite-plugin-env-dts'
{
//...
plugins:[EnvDTS({
//... options
})]
}
- type: string
- default: 'types/vite-env.d.ts'
- type: string
- default: 'VITE_'
- type: "constant" | "auto" | ((x: any) => any);
- default: 'auto'
//souce
{foo:1,bar:'baz'}
//auto -> {foo:1,bar:'baz'}
//constant -> {foo:number,bar:string}
- type: "tuple" | "array";
- default: 'array'
//souce
[100,'baz']
//tuple -> [number,string]
//array -> Array<number|string>