Home

Awesome

vite-plugin-mpa

Out-of-the-box multi-page-application (MPA) support for Vite - supports Vue2/3, React and others

<p align="center"> <img alt="wakatime" src="https://wakatime.com/badge/github/IndexXuan/vite-plugin-mpa.svg" /> <a href="https://github.com/IndexXuan/vite-plugin-mpa/actions/workflows/npm-publish.yml"> <img alt="NPM Publish" src="https://github.com/IndexXuan/vite-plugin-mpa/actions/workflows/npm-publish.yml/badge.svg" style="max-width:100%;"> </a> <a href="https://www.npmjs.com/package/vite-plugin-mpa" rel="nofollow"> <img alt="downloads" src="https://img.shields.io/npm/dt/vite-plugin-mpa.svg"> </a> <a href="https://www.npmjs.com/package/vite-plugin-mpa" rel="nofollow"> <img alt="npm version" src="https://img.shields.io/npm/v/vite-plugin-mpa.svg" style="max-width:100%;"> </a> <a href="https://github.com/IndexXuan/vite-plugin-mpa/blob/main/LICENSE"> <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" style="max-width:100%;"> </a> </p>

Motivation

Usage

yarn add vite-plugin-mpa
// vite.config.ts
import mpa from 'vite-plugin-mpa'

// @see https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // ...other plugins
    mpa(/* options */),
  ],
})

Options

{
  /**
   * open url path when server starts (customizable)
   * @default path of first-page
   */
  open: string
  /**
   * where to locate pages
   * @default 'src/pages', e.g. src/views
   */
  scanDir: string
  /**
   * how to locate page files (passed to fast-glob), e.g. index.{js,jsx}
   * @default 'main.{js,ts,jsx,tsx}'
   */
  scanFile: string
  /**
   * what is your html file name, e.g. index.html / main.html / entry.html / template.html
   * @default 'index.html'
   */
  filename: string
}

Examples

How It Works

Further Info