Registry /
web-framework / vite-plugin-virtual-mpa
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
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
createMpaPlugin
✓ import { createMpaPlugin } from 'vite-plugin-virtual-mpa'
✗ const createMpaPlugin = require('vite-plugin-virtual-mpa')
ESM-only; the plugin ships ESM and TypeScript definitions. CJS require will fail.
createPages
✓ import { createPages } from 'vite-plugin-virtual-mpa'
Helper function for typed page creation; entirely optional.
MpaOptions
✓ import type { MpaOptions } from 'vite-plugin-virtual-mpa'
Type-only import; can be used to type the options object externally.
default
✓ import vitePluginVirtualMpa from 'vite-plugin-virtual-mpa'
✗ import { default } from 'vite-plugin-virtual-mpa'
Default export is not exposed; use named import 'createMpaPlugin' instead.
Minimal MPA setup with two pages (index, about) using EJS template and custom rewrite rule.
// vite.config.ts
import { defineConfig } from 'vite';
import { createMpaPlugin, createPages } from 'vite-plugin-virtual-mpa';
const pages = createPages([
{
name: 'index',
filename: 'index.html',
entry: 'src/pages/index/main.ts',
},
{
name: 'about',
filename: 'about.html',
entry: 'src/pages/about/main.ts',
template: 'src/pages/about/template.html', // custom EJS template
},
]);
export default defineConfig({
plugins: [
createMpaPlugin({
pages,
verbose: true,
rewrites: [
{ from: '/about', to: '/about.html' },
],
transformHtml: (html, { page }) => {
// inject page-specific meta tags
return html.replace('</head>', `<meta name="page" content="${page.name}"></head>`);
},
}),
],
});
Errors
Common errors & fixes
Error: [vite-plugin-virtual-mpa] Failed to compile EJS template: Could not find matching close tag for "<% %>"
EJS syntax error in a template file (e.g., unclosed tag).
fixFix EJS syntax (e.g., close all <% %> tags). Check for missing closing '%>'. The plugin stops dev server on EJS error in recent versions.
TypeError: createMpaPlugin is not a function
CommonJS require() used instead of ESM import.
fixReplace `const { createMpaPlugin } = require(...)` with `import { createMpaPlugin } from 'vite-plugin-virtual-mpa'`. [plugin:vite-plugin-virtual-mpa] Cannot find module 'src/pages/.../main.ts'
Entry file specified in page config does not exist at the given path.
fixCheck the 'entry' path relative to project root. Ensure the file exists.
Error: Page name must not contain '/'
Page 'name' contains a slash character.
fixRemove slashes from page name; use only alphanumerics, hyphens, underscores.
Audit
Dependencies
viterequiredPeer dependency, core build tool