Skip to content

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

@jacobfrantz1

Description

@jacobfrantz1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bug 🔨An edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions