Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dishait/vite-plugin-env-types

Automatically generate env type | 自动生成环境变量类型
https://github.com/dishait/vite-plugin-env-types

dts env plugin types typescript vite

Last synced: 2 days ago
JSON representation

Automatically generate env type | 自动生成环境变量类型

Awesome Lists containing this project

README

        

# vite-plugin-env-types

Automatically generate env type


## Motivation

Want to automatically get prompted for `import.meta.env` instead of managing it manually 👉 [vitejs.dev/guide/env-and-mode](https://vitejs.dev/guide/env-and-mode.html#intellisense-for-typescript)


## Usage

### install

```shell
npm i vite-plugin-env-types -D
```


### config

```ts
// vite.config.ts
import { defineConfig } from "vite";
import EnvTypes from "vite-plugin-env-types";

export default defineConfig({
plugins: [
EnvTypes({
dts: './types/.env.d.ts' // Write file location, default to "env.d.ts"
}),
],
});
```

```json5
// tsconfig.json
{
"include": ["./env.d.ts"] // Ensure that files are scanned
}
```


## License

Made with [markthree](https://github.com/markthree)

Published under [MIT License](./LICENSE).