Open
Description
Documentation is
- Missing
- Outdated
- Confusing
- Not sure?
Explain in Detail
I know I can exclude code from production by wrapping it in if (import.meta.env.DEV) { /* exclude me */ }
. But it doesn't say this any where explicitly in the docs!
I just spent 15 minutes looking for it in order to send links to my colleagues and ended up instead linking to this comment in the issues and this stack overflow.
Surely this useful feature warrants a paragraph?
Your Suggestion for Changes
Add a paragraph like
Conditional Compilation
Code can be included only in certain modes by wrapping it in conditionals based on the Vite import.meta.env
values.
For example:
if (import.meta.env.DEV) {
// code inside here will only be included when import.meta.env.DEV is true.
console.log('Dev mode')
}
Reproduction
No response
Steps to reproduce
No response