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

Plugin is transforming string "false" options in define to true #480

Open
8 of 9 tasks
jacobfrantz1 opened this issue Nov 25, 2024 · 2 comments · May be fixed by #495
Open
8 of 9 tasks

Plugin is transforming string "false" options in define to true #480

jacobfrantz1 opened this issue Nov 25, 2024 · 2 comments · May be fixed by #495
Labels
p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)

Comments

@jacobfrantz1
Copy link

Related plugins

Describe the bug

Vite describes in the docs that define values should be a string with a json value, or any value that will automatically be json stringified later. VUE_PROD_DEVTOOLS, VUE_PROD_HYDRATION_MISMATCH_DETAILS, and VUE_OPTIONS_API are forced to true by this plugin if given a string value.

This code: https://github.com/vitejs/vite-plugin-vue/blob/599f81369816aca918314e86f5b0a6e32367bb38/packages/plugin-vue/src/index.ts#L244C1-L258C1 does not respect a falsy value if it is already stringified.

I'm using the quasar framework for some production apps and in their latest beta/rc they stringify all the defines before passing them to vite. If they are in the wrong for doing that, I'll open an issue with them.

Reproduction

https://github.com/jacobfrantz1/vite-vue-issue-repro

Steps to reproduce

Run npm install, npm run build and npm run preview. See that devtools are enabled in production although

define: {
    __VUE_PROD_DEVTOOLS__: "false",
  },

is in the vite config.

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (16) x64 AMD Ryzen 9 6900HX with Radeon Graphics
    Memory: 3.97 GB / 14.86 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.11.0/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
  Browsers:
    Chrome: 131.0.6778.85
    Chromium: 131.0.6778.85
  npmPackages:
    @vitejs/plugin-vue: ^5.1.4 => 5.2.0 
    vite: ^5.4.10 => 5.4.11

Used Package Manager

npm

Logs

No response

Validations

@edison1105 edison1105 added p2-has-workaround 🍰 Bug, but has workaround (priority) and removed pending triage labels Nov 27, 2024
@jacobfrantz1
Copy link
Author

I think acb57c9 is the commit that causes this issue.

@edison1105 edison1105 added p3-minor-bug 🔨 An edge case that only affects very specific usage (priority) and removed p2-has-workaround 🍰 Bug, but has workaround (priority) labels Dec 24, 2024
@edison1105 edison1105 linked a pull request Dec 24, 2024 that will close this issue
9 tasks
@edison1105
Copy link
Member

try this pre-release packages #495 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants