Registry / devops / rollup-plugin-posthtml

rollup-plugin-posthtml

JSON →
library1.1.0jsnpmunverified

Rollup plugin to process HTML files using PostHTML. Current stable version is 1.1.0 (released sporadically, no fixed cadence). It integrates PostHTML into the Rollup build pipeline, allowing HTML transformation via PostHTML plugins. Unlike generic HTML loaders, it passes options directly to PostHTML's .process method, supports include/exclude patterns, and can emit files as Rollup assets. Suitable for projects that need to transform HTML with PostHTML plugins during Rollup bundling.

npm install rollup-plugin-posthtml
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-POST
R
rollup-plugin-posthtml
devopsjavascriptv1.1.0
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.

default
import rollupPluginPosthtml from 'rollup-plugin-posthtml'
import { rollupPluginPosthtml } from 'rollup-plugin-posthtml'
Package exports a single default function. Named import will fail.
default
const rollupPluginPosthtml = require('rollup-plugin-posthtml')
const { rollupPluginPosthtml } = require('rollup-plugin-posthtml')
CommonJS require returns the default exported function directly.
rollupPluginPosthtml
import rollupPluginPosthtml from 'rollup-plugin-posthtml'
The function is typically used as a plugin in Rollup config.

Example Rollup config using rollup-plugin-posthtml with custom PostHTML plugins and include pattern.

import rollupPluginPosthtml from 'rollup-plugin-posthtml'; import posthtml from 'posthtml'; import include from 'posthtml-include'; export default { input: 'src/index.js', plugins: [ rollupPluginPosthtml({ plugins: [ include() ], include: '**/*.html' }) ], output: { dir: 'dist', format: 'esm' } };
Debug
Known issues
gotchaOptions are passed directly to PostHTML's .process method, so options like 'plugins', 'parser', etc. are PostHTML-specific, not Rollup plugin options.
fix
Consult PostHTML documentation for valid options; do not pass Rollup plugin options like 'output' to the options object.
affects: >=1.0.0
gotchaThe plugin only processes files that are imported or loaded in the Rollup bundle. HTML files not referenced by any module will not be processed.
fix
Ensure your HTML files are imported or use Rollup's plugin configuration to handle them as entry points.
affects: >=1.0.0
deprecatedThe plugin's option 'emitFiles' (v1.0.0) was replaced by a built-in 'emit' feature in v1.1.0.
fix
Upgrade to v1.1.0 and remove custom emit logic; use the plugin's built-in file emission.
affects: >=1.0.0 <1.1.0
breakingIn v1.1.0, the plugin started emitting files as Rollup assets by default. This may cause unexpected output files if you were not expecting it.
fix
Set option 'emit: false' if you do not want automatic file emission.
affects: >=1.1.0
Errors
Common errors & fixes
Error: Could not resolve 'posthtml-include' from 'rollup-plugin-posthtml'
Missing PostHTML plugin dependency in user's project.
fix
Install the PostHTML plugin: npm install posthtml-include --save-dev
TypeError: rollupPluginPosthtml is not a function
Using named import instead of default import.
fix
Use default import: import rollupPluginPosthtml from 'rollup-plugin-posthtml'
The 'options' argument must not be an array
Passing an array of plugins directly as options instead of object with 'plugins' key.
fix
Wrap plugins in an object: rollupPluginPosthtml({ plugins: [...] })
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
posthtmlrequiredCore dependency for HTML processing
rolluprequiredPeer dependency; plugin is designed to work with Rollup
Agent activity
4 hits · last 30 days
node
4
Resources