A Vite plugin that uses the beasties library to automatically identify, inline, and prune critical CSS in HTML pages during build. Current stable version is 0.4.2, with active development and monthly releases. Key differentiators: integrates directly with Vite's transformIndexHtml hook, supports multiple preload strategies (swap, media, JS-based), can prune inlined styles from external CSS files, and respects Vite's public path handling. Compared to critters or other critical CSS tools, it offers a more seamless Vite integration and broader preload strategy options.
npm install vite-plugin-beastiesVerified import paths — ran on the pinned version, not inferred.
Configures vite-plugin-beasties with swap preload strategy, source pruning, and 4KB inline threshold.
Ensure your CSS is valid or test with postcss-safe-parser.
Move beasties options into the `options` property.
Use a separate approach for dev (e.g., critical CSS loader).
Set pruneSource: false if you want to keep original stylesheets.
npm install -D beasties
import { beasties } from 'vite-plugin-beasties'Ensure the CSS file exists and is included in Vite's build pipeline