vite-plugin incorrectly aliases production builds with alternative mode names #17859
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
What happened?
Our team uses abbreviated build mode names
vite build --mode=prd
, but this linequasar/vite-plugin/src/vite-config.js
Line 49 in 0ad237f
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:process.env.NODE_ENV === 'production'
, notenvConfig.mode === 'production'
.envConfig.command !== 'build'
instead ofenvConfig.mode == 'production'
Reproduction URL
https://stackblitz.com/edit/vitejs-vite-rh8eamlj
How to reproduce?
vite build --mode prd
(ornpm run build:prd
in the stackblitz).mode: prd NODE_ENV: production
.npx vite-bundle-visualizer
) to observedist/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
The text was updated successfully, but these errors were encountered: