@quasar/vite-plugin treats vite build with custom mode as 'development' #17942
Labels
area/cli
bug/1-hard-to-reproduce
A reproduction is available, but it's hard to reproduce, so it has a lower priority.
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?
I was trying to use vite's custom mode to create a build which uses a different .env file:
"scripts": {
"dev": "vite",
"testbuild": "vite build --mode test",
"build": "vite build",
...
It turned out that running "npm run testbuild" resulted in files about twice as big compare to what was produced by "npm run build".
At first I was trying to do things like setting "NODE_ENV=production" in commands and in .env files, without any effect, before I learned that "vite build" always uses production setting.
Eventually I found that what causes the problem is the "@quasar/vite-plugin", specifically this code:
quasar/vite-plugin/src/vite-config.js
Line 49 in eb83a13
It treats only the vite mode called 'production' as production one, which is wrong. The code should use different vite variables to determine whether it's production or not (the equivalent of import.meta.env.PROD: https://vite.dev/guide/env-and-mode.html).
What did you expect to happen?
"@quasar/vite-plugin" should not be treating vite's custom modes as 'development' ones.
Code at
quasar/vite-plugin/src/vite-config.js
Line 49 in eb83a13
should be fixed to use different mechanism to decide whether vite is running in 'production' or not (probably checking the NODE_ENV variable: https://vite.dev/guide/env-and-mode.html#node-env-and-modes)
Reproduction URL
quasar/vite-plugin/src/vite-config.js
Line 49 in eb83a13
How to reproduce?
"testbuild": "vite build --mode test",
Flavour
Vite Plugin (@quasar/vite-plugin)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)
Platforms/Browsers
No response
Quasar info output
Relevant log output
Additional context
No response
The text was updated successfully, but these errors were encountered: