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

Set production or development in conditions #3994

Open
benmccann opened this issue Nov 29, 2024 · 2 comments
Open

Set production or development in conditions #3994

benmccann opened this issue Nov 29, 2024 · 2 comments

Comments

@benmccann
Copy link

It would be nice if conditions always included development or production

E.g. vite build will automatically set the production condition while vite dev will automatically set the development condition

References:
https://vite.dev/config/shared-options#resolve-conditions
https://vite.dev/guide/env-and-mode#node-env-and-modes

Libraries like Svelte rely on this to be set. This works automatically in Vite, but requires extra configuration in esbuild

If the user has not provided either production or development then set production by default or development if NODE_ENV === 'development'

@hyrious
Copy link

hyrious commented Nov 30, 2024

esbuild doesn't check NODE_ENV in its Go code. It does set process.env.NODE_ENV = "production" when all minification options are enabled. Maybe the same logic can be applied to the conditions field.

@benmccann
Copy link
Author

That seems reasonable as conditions and NODE_ENV should always be in sync as it would cause confusion to have their values differ

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