vite-plugin-virtual-mpa weekly downloads statistics
By emosheeep (2 listings) · npm · Vite plugins
Out-of-box MPA plugin for Vite, with html template engine and virtual files support.
vite-plugin-virtual-mpa has 24,827 recorded weekly downloads on npm, an increase of 17.6% over the past 30 days, ranking #971 of 3,247 tracked listings.
About vite-plugin-virtual-mpa
vite-plugin-virtual-mpa ⚡
Out-of-box MPA plugin for Vite 📦, with html template engine and virtual files support, generate multiple entries using only one template.
English | 中文
Features
- 💡 EJS Template Capability
- 💡 Fully Typed APIs and Prompts, Tiny and Pretty.
- 🛠️ Customize the path of generated files, generate multiple files using only one template.
- 🛠️ MPA support and History Fallback API for both dev and preview server.
Quick Start
View the cloud ide on stackblitz.com, and setup with the following scripts:
pnpm install
cd example
pnpm serve/build
Then you can try whatever you want.
Usage
pnpm add -D vite-plugin-virtual-mpa # or npm/yarn
// vite.config.ts
import { createMpaPlugin, createPages } from 'vite-plugin-virtual-mpa'
// @see https://vitejs.dev/config/
export default defineConfig({
plugins: [
createMpaPlugin({
pages: [
/**
* You can write pages configuration here directly.
* Or use `createPages` function independently outside and then pass result to this field.
*/
]
}),
],
})
/**
* This function simply converts the arguments to an array and returns them.
* It helps creating pages configuration with type hints independently outside plugin function.
* It may also simplify your configurations because you can manage them uniformly somewhere.
*/
const pages = createPages([
// You can pass a single page object or a pages array.
])
// @see https://vitejs.dev/config/
export default defineConfig({
plugins: [
createMpaPlugin({
pages,
}),
],
})
Options
type FilterPattern = string | RegExp | (string | RegExp)[]
type RewriteRule = false | Rewrite[]
interface WatchHandler {
(ctx: {
server: ViteDevServer,
file: string,
type: Event
/**
* You can update the pages configuration by calling this function.
* @params pages Your MPA core configurations, which will replace default `pages` config
*/
reloadPages: (pages: Page[]) => void
}): void
}
interface MpaOptions {
/**
* whether to print log
* @default true
*/
verbose?: boolean,
/**
* default template file
* @default index.html
*/
template?: `${string}.${'ejs' | 'html'}`,
/**
* Configure your rewrite rules, only proceed html requests.
* @see https://github.com/bripkens/connect-history-api-fallback
*/
rewrites?: RewriteRule,
/**
* Configure your preview server's rewrite rules.
* @see https://github.com/bripkens/connect-history-api-fallback
*/
previewRewrites?: RewriteRule,
/**
* Dedicated hook for transforming template HTML, inherit from `transformIndexHtml`.
* @see https://vitejs.dev/guide/api-plugin#transformindexhtml
*/
transformHtml?: (
html: string,
ctx: IndexHtmlTransformContext & { page: Page },
) => IndexHtmlTransformResult;
/**
* Use to scan directories that have similar structure to generate pages.
* Detected pages will be appended to `pages` option, page with name existed will be ignored.
*/
scanOptions?: {
/**
* Directory path to scan, subdirectory's name will be used as unique page name.
*/
scanDirs: string | string[];
/**
* The entry file path relative to scanned dir.
*/
entryFile?: string;
/**
* Customize the virtual file name(output filename).
* @param name Subdirectory name
*/
filename?: (name: string) => string;
};
/**
* Sometimes you might want to reload `pages` config or restart ViteDevServer when
* there are some files added, removed, changed and so on. You can set `watchOptions` to
* customize your own logic.
*/
watchOptions?: WatchHandler | {
/**
* Specifies the files to **include**, based on `Rollup.createFilter`
* @see https://vitejs.dev/guide/api-plugin.html#filtering-include-exclude-pattern
*/
include?: Exclude<FilterPattern, null>,
/**
* Specifies the files to **exclude**, based on `Rollup.createFilter`
* @see https://vitejs.dev/guide/api-plugin.html#filtering-include-exclude-pattern
*/
excluded?: Exclude<FilterPattern, null>,
/**
* File events you wanna deal with.
* @default ['add', 'unlink', 'change', 'unlinkDir', 'addDir']
*/
events?: Event[],
/**
* Execute your own logic when file events fired.
*/
handler: WatchHandler
},
/**
* your MPA core configurations
*/
pages: Array<{
/**
* Required. Name is used to generate default rewrite rules, it just a common string and please don't include '/'.
* You can use filename option not name option if you want to customize the path of generated files.
*/
name: string;
/**
* Relative path to the output directory, which should end with .html
* @default `${name}.html`
*/
filename?: `${string}.html`;
/**
* Higher priority template file, which will overwrite the default template.
*/
template?: string;
/**
* Entry file that will append to body. which you should remove from the html template file.
*/
entry?: string;
/**
* Data to inject with ejs.
*/
data?: Record<string, any>,
}>,
/**
* Whether to minify html file. Powered by html-minify-terser.
* @default false
* @see https://github.com/terser/html-minifier-terser
*/
htmlMinify?: Options |…
Description from the npm listing.
- vite
- vite-plugin
- virtual
- virtual-html
- html
- html-mpa
- html-template
- mpa
- multi
- multi-page
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (591)Similar npm Vite plugins plugins
All 20 vite-plugin-virtual-mpa alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-virtual-mpa. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.