{"id":13417357,"url":"https://github.com/IndexXuan/vite-plugin-html-template","last_synced_at":"2025-03-15T02:31:12.280Z","repository":{"id":40248504,"uuid":"355458474","full_name":"IndexXuan/vite-plugin-html-template","owner":"IndexXuan","description":"html template for vite, like html-webpack-plugin for webpack.","archived":false,"fork":false,"pushed_at":"2024-07-19T08:38:00.000Z","size":116,"stargazers_count":123,"open_issues_count":10,"forks_count":22,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-06T09:14:17.518Z","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-07T07:52:19.000Z","updated_at":"2024-12-29T06:29:16.000Z","dependencies_parsed_at":"2024-01-07T18:04:56.299Z","dependency_job_id":"dcade77b-cdd0-41be-b6f3-69ba07149f38","html_url":"https://github.com/IndexXuan/vite-plugin-html-template","commit_stats":{"total_commits":47,"total_committers":8,"mean_commits":5.875,"dds":"0.25531914893617025","last_synced_commit":"3395a1644a24fa9c2f813c0e5f84dd401f98a1c6"},"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-html-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-html-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-html-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexXuan%2Fvite-plugin-html-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IndexXuan","download_url":"https://codeload.github.com/IndexXuan/vite-plugin-html-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243674790,"owners_count":20329162,"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:35.730Z","updated_at":"2025-03-15T02:31:11.964Z","avatar_url":"https://github.com/IndexXuan.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# vite-plugin-html-template\n\n\u003e HTML template for vite app, like html-webpack-plugin for webpack.\n\n\u003e It works perfectly together with [vite-plugin-mpa](https://github.com/IndexXuan/vite-plugin-mpa).\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"wakatime\" src=\"https://wakatime.com/badge/github/IndexXuan/vite-plugin-html-template.svg\" /\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-html-template/actions/workflows/npm-publish.yml\"\u003e\n   \u003cimg alt=\"NPM Publish\" src=\"https://github.com/IndexXuan/vite-plugin-html-template/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-template\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dt/vite-plugin-html-template.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/vite-plugin-html-template\" rel=\"nofollow\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/vite-plugin-html-template.svg\" style=\"max-width:100%;\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/IndexXuan/vite-plugin-html-template/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 needs an html entry file, which means we must have\n  - projectRoot/index.html for SPA\n  - projectRoot/src/pages/*/index.html for MPA\n- Why not use html template for all entries\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 -D vite-plugin-html-template\n```\n\n```ts\n// vite.config.ts\nimport htmlTemplate from 'vite-plugin-html-template'\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- like [vue-cli#pages](https://cli.vuejs.org/config/#pages)\n```ts\n// for SPA, there is nothing to do, just use `public/index.html` as template\n\n// for MPA, customise the template path (default is `public/index.html`) and page title:\n{\n  // where is the pages' root directory?\n  pagesDir: 'src/pages',\n  // define pages like it is done in vue-cli\n  pages: {\n    index: {\n      template: './public/index.html',\n      title: 'Homepage',\n    },\n    subpage: {\n      template: './src/pages/subpage/index.html',\n      title: 'Subpage',\n    },\n  },\n  // expose to template\n  data: {\n    title: 'Homepage',\n  },\n}\n```\n\n- [see more](https://github.com/IndexXuan/vite-plugin-html-template/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%2FIndexXuan%2Fvite-plugin-html-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIndexXuan%2Fvite-plugin-html-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIndexXuan%2Fvite-plugin-html-template/lists"}