-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When running a production build with Vite
export function isProductionEnvironment(): boolean {
return import.meta.env && import.meta.env.PROD;
}
Is never fully removed from the build because import.meta.env.PROD is true and import.meta.env must be checked at runtime.
Alternatively, if you do:
function isDevEnv(): boolean {
return !!(import.meta.env && import.meta.env.DEV);
}
export const isDev = isDevEnv() || false;
And check for isDev (not a function) - it will be able to remove all the functions because dev is false and the const becomes false at build time.
Currently all the assertTruthy are left in at runtime as well as isProductionEnvironement() checks. You may need to do isDev && assertTruthy to fully remove them
Reproduction URL
None
Reproduction steps
`vite build`
check output in dist directoryScreenshots
Logs
Browsers
Other
Browser version
AllOS
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working