Registry / web-framework / vite-plugin-posthtml

vite-plugin-posthtml

JSON →
library0.0.3jsnpmunverified

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-posthtml
INSTALL
IMPORT
SIG · VITE-PLUGIN-POSTHT
V
vite-plugin-posthtml
web-frameworkjavascriptv0.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

posthtmlPlugin
import { posthtmlPlugin } from 'vite-plugin-posthtml'
import posthtmlPlugin from 'vite-plugin-posthtml'
ESM-only; named export, not default.
posthtmlPlugin (CommonJS)
const { posthtmlPlugin } = require('vite-plugin-posthtml')
const posthtmlPlugin = require('vite-plugin-posthtml')
CommonJS require with destructuring.
(none)
import type { PostHTMLPluginConfig } from 'vite-plugin-posthtml'
import { PostHTMLPluginConfig } from 'vite-plugin-posthtml'
TypeScript type import; config interface not exported as value.

Sets up Vite with posthtmlPlugin including a PostHTML plugin, demonstrating configuration and import.

// vite.config.js import { defineConfig } from 'vite'; import { posthtmlPlugin } from 'vite-plugin-posthtml'; // Optionally import PostHTML plugins import include from 'posthtml-include'; export default defineConfig({ plugins: [ posthtmlPlugin({ plugins: [include({ root: './src' })], options: { /* parser options, sync: false forced */ }, }), ], });
Debug
Known issues
gotchaPlugin runs only on the main HTML entry (index.html), not on other HTML files
fix
Use additional handling if you need to process multiple HTML files.
affects: >=0.0.0
gotchaThe sync option in options is always overridden to false (async mode)
fix
Do not rely on sync mode; plugins must work asynchronously.
affects: >=0.0.0
deprecatedVersion 0.0.3 may have limited support for newer Vite versions
fix
Check compatibility with your Vite version (likely 2.x or 3.x).
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: posthtmlPlugin is not a function
Default import instead of named import
fix
Use import { posthtmlPlugin } from 'vite-plugin-posthtml'
Error: Cannot find module 'posthtml'
Missing peer dependency posthtml
fix
Install the peer dependency: npm install posthtml
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
posthtmlrequiredPeer dependency for PostHTML transformations
Agent activity
10 hits · last 30 days
node
8
Perplexity
1
OpenAI (training)
1
Resources
vite-plugin-posthtml — npm install vite-plugin-posthtml · libregistry