{"id":13417175,"url":"https://github.com/IndexXuan/vite-plugin-mpa","last_synced_at":"2025-03-15T01:33:04.274Z","repository":{"id":38320125,"uuid":"339980748","full_name":"IndexXuan/vite-plugin-mpa","owner":"IndexXuan","description":"MPA(multi page application) for vite.","archived":false,"fork":false,"pushed_at":"2023-06-16T13:04:51.000Z","size":171,"stargazers_count":232,"open_issues_count":13,"forks_count":35,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T09:14:17.554Z","etag":null,"topics":["vite","vite-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IndexXuan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-18T08:17:21.000Z","updated_at":"2024-12-28T05:19:27.000Z","dependencies_parsed_at":"2024-01-07T18:04:11.035Z","dependency_job_id":"6be7b625-0eeb-422c-9e6c-ea68422d0662","html_url":"https://github.com/IndexXuan/vite-plugin-mpa","commit_stats":{"total_commits":44,"total_committers":8,"mean_commits":5.5,"dds":0.2954545454545454,"last_synced_commit":"3c31857792e4ab0b4dc166e961f3314893647940"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-mpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-mpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-mpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-mpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IndexXuan","download_url":"https://codeload.github.com/IndexXuan/vite-plugin-mpa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243671675,"owners_count":20328664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vite","vite-plugin"],"created_at":"2024-07-30T22:00:33.417Z","updated_at":"2025-03-15T01:32:59.252Z","avatar_url":"https://github.com/IndexXuan.png","language":"TypeScript","funding_links":[],"categories":["Plugins","TypeScript"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# vite-plugin-mpa\n\n\u003e Out-of-the-box multi-page-application (MPA) support for Vite - supports Vue2/3, React and others\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"wakatime\" src=\"https://wakatime.com/badge/github/IndexXuan/vite-plugin-mpa.svg\" /\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-mpa/actions/workflows/npm-publish.yml\"\u003e\n   \u003cimg alt=\"NPM Publish\" src=\"https://github.com/IndexXuan/vite-plugin-mpa/actions/workflows/npm-publish.yml/badge.svg\" style=\"max-width:100%;\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vite-plugin-mpa\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dt/vite-plugin-mpa.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vite-plugin-mpa\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/vite-plugin-mpa.svg\" style=\"max-width:100%;\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-mpa/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" style=\"max-width:100%;\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Motivation\n\n- Vite [natively supports multi-page apps](https://vitejs.dev/guide/build.html#multi-page-app), but you must configure `rollupOptions.input` manually\n- When running vite dev, you must open `localhost:3000/src/pages/index/xxx.html` for `$projectRoot/src/pages/index/xxx.html`\n- Similar to vue-cli, this plugin helps rewrite urls for MPA and auto open the first page for you\n- Experimental: when building, organize the folder for you (like vue-cli) - e.g `dist/src/pages/subpage/index.html` will move to `dist/subpage/index.html`\n\n## Usage\n\n```sh\nyarn add vite-plugin-mpa\n```\n\n```ts\n// vite.config.ts\nimport mpa from 'vite-plugin-mpa'\n\n// @see https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    // ...other plugins\n    mpa(/* options */),\n  ],\n})\n```\n\n## Options\n\n```ts\n{\n  /**\n   * open url path when server starts (customizable)\n   * @default path of first-page\n   */\n  open: string\n  /**\n   * where to locate pages\n   * @default 'src/pages', e.g. src/views\n   */\n  scanDir: string\n  /**\n   * how to locate page files (passed to fast-glob), e.g. index.{js,jsx}\n   * @default 'main.{js,ts,jsx,tsx}'\n   */\n  scanFile: string\n  /**\n   * what is your html file name, e.g. index.html / main.html / entry.html / template.html\n   * @default 'index.html'\n   */\n  filename: string\n}\n```\n\n- [see more](https://github.com/IndexXuan/vite-plugin-mpa/blob/main/src/lib/options.ts)\n\n## Examples\n\n- see [src/examples](https://github.com/IndexXuan/vite-plugin-mpa/blob/main/examples)\n\n- use shelljs after-build to organize dist folder (may be a better approach - help wanted)\n\n## How It Works\n\n- Uses fast-glob to collect all pages, e.g. src/pages/\\*/main.{js,ts}, and calc MPA entries\n- The result is passed into vite#rollupOptions#input\n\n\n## Further Info\n- [vue-cli-plugin-vite](https://github.com/IndexXuan/vue-cli-plugin-vite)\n- [vite-plugin-html-template](https://github.com/IndexXuan/vite-plugin-html-template)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIndexXuan%2Fvite-plugin-mpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIndexXuan%2Fvite-plugin-mpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIndexXuan%2Fvite-plugin-mpa/lists"}