-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
What happened?
Our team uses abbreviated build mode names vite build --mode=prd, but this line
quasar/vite-plugin/src/vite-config.js
Line 49 in 0ad237f
| if (viteMode !== 'production') { |
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 to 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:
- Production mode should be checked via
process.env.NODE_ENV === 'production', notenvConfig.mode === 'production'. - Use
envConfig.command !== 'build'instead ofenvConfig.mode == 'production'
Reproduction URL
https://stackblitz.com/edit/vitejs-vite-rh8eamlj
How to reproduce?
- Run
vite build --mode prd(ornpm run build:prdin the stackblitz). - Compare envConfig.mode to NODE_ENV:
mode: prd NODE_ENV: production. - Check bundle size (e.g.
npx vite-bundle-visualizer) to observedist/quasar.client.jsbeing included.
Flavour
Vite Plugin (@quasar/vite-plugin)
Areas
Plugins (quasar)
Platforms/Browsers
No response
Quasar info output
Relevant log output
Additional context
No response