Rollup plugin (v1.2.2, last updated Jan 2024) that imports HTML snippets, SVGs, and other XML-parseable markup as Vue single-file components. Works with both Vue 2 and 3 by generating a virtual SFC that is then compiled by rollup-plugin-vue. Key differentiators: supports functional components and v-once/v-pre directives via options; include/exclude patterns using rollup/pluginutils; ships TypeScript types. Unlike generic raw-loaders, this plugin allows using SVG files directly as Vue components with full reactivity support.
npm install rollup-plugin-htmlvueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal Rollup config to use htmlvue with vue plugin, and how to import an HTML file as a Vue component.
Use import syntax or set type: 'module' in package.json.
Wrap multiple elements in a single parent <div> or <template>.
Ensure vue() plugin is placed before htmlvue() in the plugins list.
Omit these options when targeting Vue 3, or use Vue 2 documentation for functional components.
Restrict include pattern to .html, .svg, .xml, or custom non-vue extensions.
Use import syntax: `import htmlvue from 'rollup-plugin-htmlvue'` or switch to ESM (type:"module").
Add htmlvue() to your Rollup plugins array.
Wrap all elements in a single root element, e.g., `<div><!-- content --></div>`.
Install rollup-plugin-vue: `npm i -D rollup-plugin-vue`.