{"id":20152534,"url":"https://github.com/fe6/vite-plugin-html-mpa","last_synced_at":"2025-04-09T21:24:22.762Z","repository":{"id":49510770,"uuid":"374123631","full_name":"fe6/vite-plugin-html-mpa","owner":"fe6","description":"vite 的多页面配置插件","archived":false,"fork":false,"pushed_at":"2021-06-16T07:49:35.000Z","size":121,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T17:49:17.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fe6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-05T13:39:56.000Z","updated_at":"2024-06-23T06:38:56.000Z","dependencies_parsed_at":"2022-09-26T22:10:32.668Z","dependency_job_id":null,"html_url":"https://github.com/fe6/vite-plugin-html-mpa","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fe6%2Fvite-plugin-html-mpa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fe6%2Fvite-plugin-html-mpa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fe6%2Fvite-plugin-html-mpa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fe6%2Fvite-plugin-html-mpa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fe6","download_url":"https://codeload.github.com/fe6/vite-plugin-html-mpa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247836812,"owners_count":21004478,"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":[],"created_at":"2024-11-13T23:12:22.701Z","updated_at":"2025-04-09T21:24:22.733Z","avatar_url":"https://github.com/fe6.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-html-mpa\n\n\u003e HTML template for vite app, like html-webpack-plugin for webpack.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"wakatime\" src=\"https://wakatime.com/badge/github/IndexXuan/vite-plugin-html-mpa.svg\" /\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-html-mpa/actions/workflows/npm-publish.yml\"\u003e\n   \u003cimg alt=\"NPM Publish\" src=\"https://github.com/IndexXuan/vite-plugin-html-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-html-mpa\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dt/vite-plugin-html-mpa.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vite-plugin-html-mpa\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/vite-plugin-html-mpa.svg\" style=\"max-width:100%;\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-html-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 need html for entry file, which means we must have\n  - projectRoot/index.html for SPA\n  - projectRoot/src/pages/*/index.html for MPA\n- Why not we use html template for all entry html\n- Also we should support ejs/lodash.template syntax for the html content, like setting `\u003ctitle\u003e\u003c/title\u003e`.\n\n## Usage\n\n```sh\nyarn add vite-plugin-html-mpa\n```\n\n```ts\n// vite.config.ts\nimport htmlTemplate from 'vite-plugin-html-mpa'\n\n// @see https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [\n    // ...other plugins\n    htmlTemplate(/* options */),\n  ],\n})\n```\n\n## Options\n\n[例子参考](https://github.com/fe6/water-pro)\n\n```ts\n// for SPA, you can do nothing, auto reuse public/index.html as template\n\n// for MPA, you can custom template path(default is public/index.html) and page title\n{\n  // where pages ?\n  pagesDir: 'src/pages',\n  // define pages like vue-cli\n  pages: {\n    index: {\n      template: './public/index.html',\n      title: 'Home Page',\n    },\n    subpage: {\n      template: './src/pages/subpage/index.html',\n      title: 'Sub Page',\n    },\n  },\n  // expose to template\n  data: {\n    title: 'Home Page',\n  },\n}\n```\n\n- [更多配置](https://github.com/IndexXuan/vite-plugin-html-mpa/blob/main/src/lib/options.ts)\n\n\n## Underlying\n- Thanks to [vite-plugin-virtual-html](https://github.com/Windson1806/vite-plugin-virtual-html)\n- Thanks to [vite-plugin-vue-cli](https://github.com/IndexXuan/vite-plugin-vue-cli/blob/main/src/index.ts#L165)\n\n\n## Further\n- [vue-cli-plugin-vite](https://github.com/IndexXuan/vue-cli-plugin-vite)\n- [vite-plugin-mpa](https://github.com/IndexXuan/vite-plugin-mpa)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffe6%2Fvite-plugin-html-mpa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffe6%2Fvite-plugin-html-mpa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffe6%2Fvite-plugin-html-mpa/lists"}