vite-env
v1.0.0
Published
Easily add the import.meta types from vite and vitest to your TypeScript project
Downloads
7
Readme
vite-env
This package exists to make it easy to get the right behavior for import.meta
when using vite
and (optionally) vitest.
Installation
$ pnpm add -D vite-env
Add this to your tsconfig:
{
"compilerOptions": {
"types": ["vite-env"]
}
}
Usage
Once you've done that, you can use import.meta
features from Vite and Vitest:
if (import.meta.env.DEV) {
console.log("DEV");
}
if (import.meta.vitest) {
const { describe, it } = import.meta.vitest;
}
Included Features
import.meta.env.DEV
import.meta.env.PROD
import.meta.env.MODE
import.meta.vitest
Implementation
For the most part, this package pulls in types published by vite and vitest. At the moment, the best practices for doing this correctly have been in flux and not always easy to figure out.
If this changes and the guidance becomes stable and easy to find, this package will no longer need to exist.
License
MIT © Yehuda Katz and Starbeam Contributors