1.0.0 • Published 7 months ago

vite-env v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

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

1.0.0

7 months ago