A Rollup plugin that imports HTML files as strings and optionally transforms them with PostHTML. Version 1.3.0 is the latest stable release. It enables importing .html files directly in JavaScript, supports custom PostHTML plugins (e.g., posthtml-include), template interpolation, custom parsers (e.g., sugarml), and directives. Differentiators: lightweight, focuses on PostHTML integration for HTML transformations within Rollup builds, with first-class TypeScript support.
npm install rollup-plugin-posthtml-templateVerified import paths — ran on the pinned version, not inferred.
Configures Rollup to import HTML files as strings using the PostHTML plugin.
Install both: npm install rollup posthtml --save-dev
If template option enabled, call the import as a function: `import tmpl from './file.html'; tmpl({ data })`Pass a string parser name or a PostHTML parser object instead.
Refer to the PostHTML documentation for the correct plugin format.
Consider using 'rollup-plugin-hot' or configure your dev server to reload on HTML changes.
Run: npm install rollup-plugin-posthtml-template --save-dev
Use: import posthtml from 'rollup-plugin-posthtml-template' (default import)
Install missing peer dependencies: npm install posthtml rollup --save-dev
Ensure the project uses ESM (type: "module" in package.json) and import syntax.