Automatically generate env type
Want to automatically get prompted for import.meta.env
instead of managing it manually 👉 vitejs.dev/guide/env-and-mode
npm i vite-plugin-env-types -D
// 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
}
Made with markthree
Published under MIT License.