vite-plugin-vue-tracer is a development-only Vite plugin designed to trace the source code location of elements and Virtual DOM nodes within Vue Single-File Components (SFCs). It serves as a modern replacement for `vite-plugin-vue-inspector`, leveraging Vite's internal source map capabilities to resolve source locations without injecting additional data attributes into the DOM. This approach aims for cleaner DOM and improved performance. The current stable version is `1.3.0`. The project maintains an active release cadence, frequently updating to support the latest versions of Vite and Vue DevTools. It differentiates itself by offering both a built-in overlay UI and headless APIs, allowing developers to build custom inspection tools or integrate tracing functionality more deeply into their development workflow.
npm install vite-plugin-vue-tracerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `vite-plugin-vue-tracer` into a Vite project, enabling the built-in development overlay and listening for hover and click events to trace Vue component source locations. It shows both plugin configuration and client-side integration.
Always refer to the latest README and changelog for the correct configuration when integrating with Vite DevTools. Ensure your `vite` and `@vitejs/devtools-kit` versions are compatible with the plugin version.
Always wrap client-side imports and logic with `if (import.meta.hot)` to ensure they are only active during development and are tree-shaken from production builds.
Explicitly enable Vite DevTools integration if needed by consulting the latest plugin configuration options, or utilize the headless client APIs to build custom integrations.
Ensure your project's `vite` and `vue` versions satisfy the declared peer dependency ranges for `vite-plugin-vue-tracer`. Upgrade or downgrade dependencies as necessary.
Ensure the client-side import is properly asynchronous (`.then()`) and strictly guarded by `if (import.meta.hot)` to ensure the module is only loaded and executed when HMR is active in development.
Upgrade your project's `vite` dependency to a compatible version (6.x or 7.x) using `npm install vite@latest` or `yarn add vite@latest` and verify it matches the required range.
Run `npm install -D vite-plugin-vue-tracer` or `yarn add -D vite-plugin-vue-tracer` to ensure the package is installed. Verify the import path in `vite.config.ts`.
Ensure `VueTracer` is imported as a named export: `import { VueTracer } from 'vite-plugin-vue-tracer'`. Also verify it's correctly called as a function: `VueTracer()`.