Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite built-in env inconsistent with typing #26

Closed
melishev opened this issue Aug 18, 2024 · 2 comments
Closed

Vite built-in env inconsistent with typing #26

melishev opened this issue Aug 18, 2024 · 2 comments

Comments

@melishev
Copy link

In the vite-inv.d.ts file, I get content like this:

/// <reference types="vite-envs/client" />

type ImportMetaEnv = {
  // Auto-generated by `npx vite-envs update-types` and hot-reloaded by the `vite-env` plugin
  // You probably want to add `/src/vite-env.d.ts` to your .prettierignore
  BASE_URL: string
  MODE: string
  DEV: boolean
  PROD: boolean

The problem is that when calling import.meta.env.PROD I will get a string, which seems to be normal behavior for an environment variable, so why the confusion?

@garronej
Copy link
Owner

Hello @melishev,

This is a bug. Thank you for reporting it. I'll release a new version with a fix

garronej added a commit that referenced this issue Aug 18, 2024
@garronej
Copy link
Owner

It's fixed in 4.3.3.
The runtime values you're getting matches the type definitions.

Aditionally this release makes vite-envs self contained. (It won't add any thing to your node module but itself)

garronej added a commit that referenced this issue Aug 19, 2024
garronej added a commit that referenced this issue Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants