{"id":22749,"library":"vite-plugin-mpa","title":"vite-plugin-mpa","description":"Vite plugin that provides out-of-the-box multi-page application (MPA) support for any framework (Vue, React, etc.). Version 1.2.0 automatically configures rollupOptions.input for all pages found via glob scanning, rewrites dev server URLs so you can open clean paths like /subpage/ instead of /src/pages/subpage/index.html, and auto-opens the first page on dev start. It also optionally reorganizes the build output folder structure (e.g., moving dist/src/pages/subpage/index.html to dist/subpage/index.html). Actively maintained, weekly releases, with TypeScript types included.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/IndexXuan/vite-plugin-mpa","tags":["javascript","vite-plugin","mpa","MPA","multi-page","typescript"],"install":[{"cmd":"npm install vite-plugin-mpa","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-mpa","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-mpa","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to scan for page entry files and HTML templates.","package":"fast-glob","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const mpa = require('vite-plugin-mpa')","symbol":"mpa","correct":"import mpa from 'vite-plugin-mpa'"},{"note":"Options are scanDir, scanFile, filename, open — not an explicit pages list.","wrong":"mpa({ pages: ['page1', 'page2'] })","symbol":"mpa (with options)","correct":"mpa({ scanDir: 'src/views', scanFile: 'index.{js,ts,jsx,tsx}', filename: 'template.html' })"},{"note":"Available for TypeScript users; not required for JavaScript.","wrong":"","symbol":"MpaOptions","correct":"import type { MpaOptions } from 'vite-plugin-mpa'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite'\nimport mpa from 'vite-plugin-mpa'\n\nexport default defineConfig({\n  plugins: [mpa({\n    scanDir: 'src/pages',\n    scanFile: 'main.{js,ts}',\n    filename: 'index.html',\n    open: '/page1/'\n  })]\n})","lang":"typescript","description":"Basic setup with custom scan directory, entry file pattern, HTML filename, and URL to open on dev start."},"warnings":[{"fix":"Upgrade Vite to 2.0.0 or later.","message":"Plugin requires Vite >=2.0.0; older versions not supported.","severity":"gotcha","affected_versions":"<1.0.0 || Vite <2.0.0"},{"fix":"Ensure each page folder contains an HTML file (default: index.html).","message":"The plugin only rewrites the dev server URL; it does not generate HTML files. You must have an index.html in each page directory matching the 'filename' option.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to v1.1.0+ to customize the open URL.","message":"The 'open' option was added in v1.1.0; in v1.0.0 the first page was always opened automatically.","severity":"deprecated","affected_versions":"1.0.0"},{"fix":"Consider using a postbuild script with shelljs or a build tool.","message":"Build output reorganization is experimental and may not work as expected; use shell scripts as a more reliable alternative.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package: yarn add vite-plugin-mpa -D / npm install vite-plugin-mpa --save-dev","cause":"Package not installed or ESM-only nature not handled.","error":"Cannot find module 'vite-plugin-mpa'"},{"fix":"Use ES module import: import mpa from 'vite-plugin-mpa'","cause":"Using CommonJS require() which returns an object instead of the default export.","error":"TypeError: mpa is not a function"},{"fix":"Verify that pages exist at the configured scanDir with the correct entry file (e.g., main.js) and HTML (index.html).","cause":"Glob pattern does not match any page files.","error":"Error: No pages found. Check your scanDir, scanFile, and filename options."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}