A Vite plugin (v2.0.9) that gives React and Vue developers precise control over where CSS stylesheets are injected in the component tree, addressing a common pain point with Shadow DOM and scoped styles. Unlike traditional CSS injection at the document head, this plugin allows placement at any arbitrary location via the StylesTarget component. It ships TypeScript types, supports HMR in dev mode when enabled, and has zero runtime dependencies beyond peer requirements (React 19 / Vue 3.5.22). Semi-active development with monthly releases. Differentiator: fine-grained DOM insertion point control without ejecting from Vite.
npm install vite-plugin-css-positionVerified import paths — ran on the pinned version, not inferred.
Shows Vite plugin configuration and usage of StylesTarget component in a React app.
Upgrade to React 19 or Vue 3.5.22+. If you must use older versions, stick to v1.x.
Set enableDev: true in viteCssPosition options to enable development injection and HMR.
Use 'instanceId' instead of 'customId'.
Always wrap StylesTarget in a parent element (e.g., <div><StylesTarget /></div>).
Use only React or only Vue in a project. Do not mix frameworks.
Use import { viteCssPosition } from 'vite-plugin-css-position'; and ensure your Vite config or tsconfig has 'moduleResolution' set to 'bundler' or 'node16'.Upgrade Node to >=14.13 or use a bundler that supports the 'exports' field (Vite, webpack 5, etc.). Alternatively, import from 'vite-plugin-css-position/dist/react.js' as a fallback.
Ensure viteCssPosition() is added to plugins array before react() or vue() plugin. Also check that 'enableDev' is set to true in development.
No dependency data recorded yet.