Skip to content

Unhead devtools plugin breaks if vite devtools plugin is specified after other plugins using it #938

Description

@solonovamax

Environment

  • unhead: 3.3.1
  • node.js: v26.4.0
  • package manager: pnpm 11.20.0

Reproduction

I will make a minimal reproduction sample when I have time later, I just want to report this before I forget. (feel free to remind me if I do forget to provide one in the next few days)

Describe the bug

The unhead vite devtools plugin will fail to work if the @vitejs/devtools plugin is applied after another plugin using it.
If @vitejs/devtools is applied after a another plugin using it, then the unhead devtool panel will not show any of the tags that you added, no matter what you do. (maybe it fails to inject the hooks? unsure.)

The specific scenario I ran into it had my vite config looking somewhat like this

// ...
import {Unhead} from "@unhead/vue/vite";
import {DevTools} from "@vitejs/devtools";
import UnocssVitePlugin from "unocss/vite";
// ...

export default defineConfig(async ({command, mode}) => {
  // ...

  return {
    // ...
    plugins: [
      // ...
      UnocssVitePlugin({ /* ... */ }),
      DevTools({ /* ... */ }),
      // ...
      Unhead({ /* ... */ }),
      // ...
    ],
    // ...
  };
});

but I suspect that this will also likely happen if you apply the devtools plugin and then the unhead plugin, and that the unocss plugin is not necessary for this.

in this case however, unhead was applied after the devtools plugin, but this still caused unhead to fail, which is quite peculiar.

This one was quite an annoying issue to debug, because there was no obvious sign of the failure other than the fact that it just didn't show up (i.e. nothing in the vite logs or the browser console), instead I had to discover it through a lot of manual trial and error.

Currently, the solution is to just move the DevTools plugin above any of the other plugins that use it.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions