{"id":30463699,"url":"https://github.com/budingxiaocai/pages-webpack-plugin","last_synced_at":"2026-04-13T08:31:39.141Z","repository":{"id":310986698,"uuid":"1042004175","full_name":"budingxiaocai/pages-webpack-plugin","owner":"budingxiaocai","description":"用于自动化多页面应用构建的 Webpack 插件 / Webpack plugin for automating the construction of multi page applications","archived":false,"fork":false,"pushed_at":"2025-08-21T12:23:19.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-13T23:14:48.832Z","etag":null,"topics":["javascript","multi-pages","webpack","webpack-plugin","webpack5","webpack5-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/budingxiaocai.png","metadata":{"files":{"readme":"README-CN.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-21T10:38:23.000Z","updated_at":"2025-10-02T08:26:43.000Z","dependencies_parsed_at":"2025-08-21T13:01:33.200Z","dependency_job_id":"b343c9f6-5f04-484a-b4ae-c7f247855291","html_url":"https://github.com/budingxiaocai/pages-webpack-plugin","commit_stats":null,"previous_names":["budingxiaocai/pages-webpack-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/budingxiaocai/pages-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budingxiaocai%2Fpages-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budingxiaocai%2Fpages-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budingxiaocai%2Fpages-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budingxiaocai%2Fpages-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/budingxiaocai","download_url":"https://codeload.github.com/budingxiaocai/pages-webpack-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/budingxiaocai%2Fpages-webpack-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31746101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T06:26:45.479Z","status":"ssl_error","status_checked_at":"2026-04-13T06:26:44.645Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["javascript","multi-pages","webpack","webpack-plugin","webpack5","webpack5-plugin"],"created_at":"2025-08-24T00:35:10.908Z","updated_at":"2026-04-13T08:31:39.121Z","avatar_url":"https://github.com/budingxiaocai.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PagesPlugin\n\n[English](https://github.com/budingxiaocai/pages-webpack-plugin/blob/master/README.md)\n\nPagesPlugin 是一个用于自动化多页面应用构建的 Webpack 插件，专为扫描目录结构并动态生成入口和 HTML 文件而设计。它支持灵活配置、伪静态路由生成，并与 `.pagerc.json` 配置文件集成，实现每个页面的个性化构建。\n\n## 特性\n- 零配置：按目录名即可生成页面\n- 短小精悍：体积小，功能多\n- 动态路由：`[id]` 目录自动映射为 `/@id@.html?id=`\n- 单页配置：`.pagerc.json` 可对单个页面做个性化设置\n\n## 安装\n```bash\nnpm i -D pages-webpack-plugin\n# 或\nyarn add -D pages-webpack-plugin\n```\n\n## 快速开始\n1. 在项目根目录新建 `webpack.config.js`：\n```javascript\nconst PagesPlugin = require('pages-plugin-webpack');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    new PagesPlugin({\n      scanDir: './src/pages',        // 可选，默认为 src\n      entryName: 'index.{tsx,jsx}'   // 可选，默认为 index.{vue,tsx,jsx,html}\n      // 其余与html-webpack-plugin字段相同\n    })\n  ]\n};\n```\n\n2. 新建目录结构\n```\nsrc/pages/\n├── home/\n│   └── index.tsx\n├── about/\n│   └── index.jsx\n└── user/\n    └── [id]/\n        └── index.tsx\n```\n\n3. 运行 `yarn build`，即可得到：\n- `home.html`\n- `about.html`\n- `user/@id@.html`（实际访问为 `/user/[id]`）\n\n## 目录约定\n| 目录名示例       | 生成路由            | 说明            |\n| ----------- | --------------- | ------------- |\n| `home`      | `/home.html`    | 普通静态页         |\n| `[id]`      | `/@id@.html?id=`     | 动态路由（参数为 `id`） |\n\n## 配置项\n插件实例化时可传入：\n| 字段          | 类型       | 默认值                        | 描述            |\n| ----------- | -------- | -------------------------- | ------------- |\n| `scanDir`   | `string` | `src`                      | 扫描页面根目录       |\n| `entryName` | `string` | `index.{vue,tsx,jsx,html}` | 入口文件名 glob 规则 |\n\n以及[html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin#options)中的所有字段\n\n## 单页配置 `.pagerc.json`\n在任意页面目录下创建 `.pagerc.json`，可覆盖全局设置（`scanDir` 除外）：\n```json\n{\n  \"entryName\": \"main.tsx\"\n  // 其余与html-webpack-plugin字段相同\n}\n```\n\n## 动态路由（伪静态）\n\n### 静态页面映射\n通过 `.htaccess` Nginx伪静态文件将 `/user` 的请求内部重定向至 `/user.html`\n```\nlocation / {\n    try_files $uri $uri.html =404;\n}\n```\n\n### 动态路由\n- 目录名使用 `[]` 包裹，如 `[id]`、`[slug]`\n- 构建后生成：`/user/@id@.html`\n- 自动生成 `.htaccess` Nginx伪静态文件\n```\nlocation ~ ^/user/([^/]+)/?$ {\n    rewrite ^/user/([^/]+)/?$ /user/@id@.html?id=$1 break;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbudingxiaocai%2Fpages-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbudingxiaocai%2Fpages-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbudingxiaocai%2Fpages-webpack-plugin/lists"}