Vite plugin for flexible multi-page app (MPA) development, allowing HTML files to be placed anywhere in the project and configured via a pages map. Current stable version is 1.2.7, released periodically since 2020. Key differentiators: eliminates Vite's default HTML root restriction, provides dev-server interception for seamless MPA development, supports EJS templating with custom render functions, and includes automatic Rollup input configuration. Compared to vanilla Vite MPA, it offers a configurable pages structure similar to @vue/cli's pages option, with additional features like injectCode and urlTransformer.
npm install vite-plugin-virtual-htmlVerified import paths — ran on the pinned version, not inferred.
Basic setup for a multi-page app with virtual-html plugin, showing pages config, indexPage fallback, and global data.
Use ESM imports (import virtualHtml from 'vite-plugin-virtual-html') or downgrade to v1.1.x
Ensure all configured HTML files exist or handle 404 gracefully
Remove manual input config; plugin auto-generates it from pages
Use 'template' key for HTML file path in page objects
Use '*' as key in injectCode to apply to all HTML files, or specify individual file paths
Set useCustom: false to revert to pre-1.2.4 behavior (appType auto-detected)
Clean up root HTML files manually if build is interrupted; known limitation
Switch to ESM import or use dynamic import()
Verify all pages paths are correct and files exist; also ensure extraGlobPattern excludes dist
Add the HTML file path to the pages config or ensure the requested URL matches a configured page
Ensure each page value is either a string path or an object: { template: 'path', data: {...} }No dependency data recorded yet.