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

@quasar/vite-plugin treats vite build with custom mode as 'development' #17942

Open
StasD opened this issue Mar 31, 2025 · 0 comments
Open

@quasar/vite-plugin treats vite build with custom mode as 'development' #17942

StasD opened this issue Mar 31, 2025 · 0 comments
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

Comments

@StasD
Copy link

StasD commented Mar 31, 2025

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:

if (viteMode !== 'production') {

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

if (viteMode !== 'production') {

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

if (viteMode !== 'production') {

How to reproduce?

  1. Add this line to "scripts" of ANY large enough Vue+Vite+Quasar project:
    "testbuild": "vite build --mode test",
  2. run "npm run testbuild", then check the output
  3. run "npm run build", also check the output and compare with the one for "testbuild".
  4. better yet, add "--debug" flag to both "build" and "testbuild", copy outputs into separate text files and compare with e.g. "Beyond Compare".

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

@StasD StasD added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Mar 31, 2025
@github-actions github-actions bot added 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 labels Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant