Skip to content

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

License

Notifications You must be signed in to change notification settings

dishait/vite-plugin-env-types

Repository files navigation

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


Usage

install

npm i vite-plugin-env-types -D

config

// 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"
    }),
  ],
});
// tsconfig.json
{
    "include": ["./env.d.ts"] // Ensure that files are scanned
}

License

Made with markthree

Published under MIT License.