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-plugin incorrectly aliases production builds with alternative mode names #17859

Open
athisun opened this issue Feb 26, 2025 · 0 comments
Open
Labels
area/plugins bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@athisun
Copy link
Contributor

athisun commented Feb 26, 2025

What happened?

Our team uses abbreviated build mode names vite build --mode=prd, but this line

if (viteMode !== 'production') {
causes the quasar package to be aliased unless the mode is strictly named "production". This causes production builds to include the dev file, hugely increasing the bundle size.

As noted by https://vite.dev/guide/env-and-mode.html#node-env-and-modes, process.env.NODE_ENV is the controlling variable driving the value of import.meta.env.PROD.

Vite builds (with any mode name) default to NODE_ENV=production, and is expected be overridden in the mode-linked .env.mode files. Users can therefore define multiple production modes, or the 'production' mode can be renamed.

What did you expect to happen?

Quasar package should not be aliased in builds with NODE_ENV=production. A solution could look like either:

  1. Production mode should be checked via process.env.NODE_ENV === 'production', not envConfig.mode === 'production'.
  2. Use envConfig.command !== 'build' instead of envConfig.mode == 'production'

Reproduction URL

https://stackblitz.com/edit/vitejs-vite-rh8eamlj

How to reproduce?

  1. Run vite build --mode prd (or npm run build:prd in the stackblitz).
  2. Compare envConfig.mode to NODE_ENV: mode: prd NODE_ENV: production.
  3. Check bundle size (e.g. npx vite-bundle-visualizer) to observe dist/quasar.client.js being included.

Flavour

Vite Plugin (@quasar/vite-plugin)

Areas

Plugins (quasar)

Platforms/Browsers

No response

Quasar info output

Relevant log output

Additional context

No response

@athisun athisun added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Feb 26, 2025
@github-actions github-actions bot added area/plugins bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/vite-plugin Bugs related to Vite usage with Quasar kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

1 participant