Vite plugin to run PostHTML transformations on served/built HTML files (index.html). Current version is 0.0.3. It supports mixing synchronous and asynchronous PostHTML plugins, runs in asynchronous mode, and allows overriding the PostHTML function. Compared to other PostHTML integrations, this plugin is specifically designed for Vite's plugin system and processes the HTML entry point.
npm install vite-plugin-posthtmlVerified import paths — ran on the pinned version, not inferred.
Sets up Vite with posthtmlPlugin including a PostHTML plugin, demonstrating configuration and import.
Use additional handling if you need to process multiple HTML files.
Do not rely on sync mode; plugins must work asynchronously.
Check compatibility with your Vite version (likely 2.x or 3.x).
Use import { posthtmlPlugin } from 'vite-plugin-posthtml'Install the peer dependency: npm install posthtml