A Vite plugin that normalizes Tailwind CSS for Shadow DOM usage by fixing two key issues: converting `:root` to `:host` so CSS custom properties apply inside Shadow DOM, and unwrapping `@supports` blocks that mention `-webkit-hyphens` to avoid breakage. Current stable version is 1.1.1, released under MIT. It runs after Tailwind processes CSS, only targeting CSS imported with a query (e.g. `?inline`). Compatible with Vite 4.x-7.x and Tailwind CSS 3.x-4.x. Lightweight with no runtime dependencies beyond Vite as a peer dependency. Differentiators: specifically solves Tailwind + Shadow DOM compatibility, minimal configuration, and respects query-based imports to avoid altering global styles.
npm install vite-plugin-tailwind-shadowdomVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up the plugin in vite.config.ts and using a ?inline CSS import inside a web component's Shadow DOM.
Ensure your Shadow DOM styles are imported with a query parameter, e.g. `import styles from './styles.css?inline'`.
If you rely on `:host-context`, consider using CSS parts or custom properties instead.
Update to the latest version: `npm install vite-plugin-tailwind-shadowdom@latest -D`
Ensure the plugin runs after Tailwind in the Vite plugin chain. It is designed to run last, so no special ordering is needed.
Redefine required custom properties inside the Shadow DOM styles or use CSS custom properties with `@property` to ensure inheritance.
Use `pnpm install` (without --prod) or add vite and the plugin as dependencies in package.json.
Correct: `import tailwindShadowDOM from 'vite-plugin-tailwind-shadowdom'`
Ensure `this.shadowRoot.adoptedStyleSheets = [sheet]` is called in `connectedCallback()` or later.
Add `?inline` to the import: `import styles from './styles.css?inline'`