Skip to content

docs: add import.meta.env.DEV examples #20352

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adithyaa-s
Copy link

@adithyaa-s adithyaa-s commented Jul 4, 2025

Description

close #20197

…import.meta.env.DEV' and 'import.meta.env.PROD' for conditional compilation in Vite projects with examples
@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Jul 7, 2025
@sapphi-red sapphi-red changed the title Issue #20197 Added new section to the 'Env Variables and Modes' guide explaining '… docs: add import.meta.env.DEV examples Jul 7, 2025
@@ -16,6 +16,31 @@ Some built-in constants are available in all cases:

- **`import.meta.env.SSR`**: {boolean} whether the app is running in the [server](./ssr.md#conditional-logic).

## Conditional Compilation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a whole section for this. I think a simple example is enough.

:::details Example
```js
if (import.meta.env.DEV) {
  // code inside here will be treeshaken
  console.log('Dev mode') 
}
```
:::

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explanation of conditional compilation in /build or /env-and-mode
2 participants