Skip to content

A plugin for Vite to auto-genarate d.ts delcaration file from .env* files

Notifications You must be signed in to change notification settings

gapkukb/vite-plugin-env-dts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-plugin-env-dts

A plugin for Vite to auto-genarate d.ts delcaration file from .env* files

Install

npm

npm i -D vite-plugin-env-dts

yarn

yarn add --dev vite-plugin-env-dts

pnpm

pnpm i -D vite-plugin-env-dts

Usage

// vite.config.{ts,js}

import EnvDTS from 'vite-plugin-env-dts'

{
    //...
    plugins:[EnvDTS({
        //... options
    })]
}

Options

Options.path

relative to your vite.config.{js,ts} file.

  • type: string
  • default: 'types/vite-env.d.ts'

Options.prefix

The constants what in your .env* files will be output in .d.ts.

  • type: string
  • default: 'VITE_'

Options.parser

custom your parser decide to what styles will be output.

  • type: "constant" | "auto" | ((x: any) => any);
  • default: 'auto'
//souce
{foo:1,bar:'baz'}
//auto -> {foo:1,bar:'baz'}
//constant -> {foo:number,bar:string}

Options.arrayType

select the array style range in tuple and array

  • type: "tuple" | "array";
  • default: 'array'
//souce
[100,'baz']
//tuple -> [number,string]
//array -> Array<number|string>

About

A plugin for Vite to auto-genarate d.ts delcaration file from .env* files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published