A Vite plugin that adds location data attributes to JSX elements for debugging and development purposes.
Installation
npm install @builder.io/vite-plugin-jsx-loc
# or
yarn add @builder.io/vite-plugin-jsx-loc
# or
pnpm add @builder.io/vite-plugin-jsx-loc
Usage
Add the plugin to your vite.config.ts:
import { defineConfig } from 'vite';
import { jsxLocPlugin } from '@builder.io/vite-plugin-jsx-loc';
export default defineConfig({
plugins: [jsxLocPlugin()],
});
This will add a data-loc attribute to all JSX elements in your code, containing the relative file path and line number where the element is defined. For example: