A Vite plugin that injects CSS into JavaScript bundle files instead of generating separate CSS files, eliminating the need for external CSS imports. Currently at v0.0.1, it targets library authors who want to distribute self-contained components without requiring consumers to import a separate CSS file. Different from CSS-in-JS solutions, this plugin works with traditional CSS files and transforms them into inline styles at build time. It requires Vite ^2.0.0 as a peer dependency and ships TypeScript definitions. Release cadence is unknown as the package is very new.
npm install vite-plugin-style-injectVerified import paths — ran on the pinned version, not inferred.
Shows how to add the plugin to Vite config and explains that CSS will be inlined into JS, removing the need for separate CSS imports.
Consider using separate CSS files for large stylesheets to allow parallel loading and caching.
Use this plugin only when building a library (e.g., `build.lib` option in Vite config). For apps, leave CSS as separate files.
N/A
Run `npm install vite-plugin-style-inject --save-dev`
Use `import VitePluginStyleInject from 'vite-plugin-style-inject'`
Upgrade Vite to version 2.0.0 or higher.