{"id":15551340,"url":"https://github.com/simmzl/vite-plugin-entries-build-cache","last_synced_at":"2025-04-23T19:24:52.790Z","repository":{"id":182221896,"uuid":"668101503","full_name":"simmzl/vite-plugin-entries-build-cache","owner":"simmzl","description":"A Vite plugin that provides a cache mechanism to speed up the multi-entry build process.","archived":false,"fork":false,"pushed_at":"2024-01-10T11:15:04.000Z","size":365,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T19:24:51.449Z","etag":null,"topics":["entries","multi-entry","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simmzl.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-19T03:13:14.000Z","updated_at":"2023-09-26T10:48:20.000Z","dependencies_parsed_at":"2025-03-06T10:32:19.003Z","dependency_job_id":"c30f315d-ac3b-46cc-aa7b-855861870bae","html_url":"https://github.com/simmzl/vite-plugin-entries-build-cache","commit_stats":null,"previous_names":["simmzl/vite-plugin-entries-build-cache"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simmzl%2Fvite-plugin-entries-build-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simmzl%2Fvite-plugin-entries-build-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simmzl%2Fvite-plugin-entries-build-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simmzl%2Fvite-plugin-entries-build-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simmzl","download_url":"https://codeload.github.com/simmzl/vite-plugin-entries-build-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250498188,"owners_count":21440429,"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":["entries","multi-entry","vite","vite-plugin"],"created_at":"2024-10-02T14:04:18.377Z","updated_at":"2025-04-23T19:24:52.744Z","avatar_url":"https://github.com/simmzl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-entries-build-cache\n\nEnglish | [简体中文](./README.zh_CN.md)\n\n`vite-plugin-entries-build-cache` is a `Vite` plugin that provides a cache mechanism to filter the input package entry based on the verification of project file changes to speed up the multi-entry build process.\n\nNote: This plugin is only applicable to multi-entry projects and only takes effect when `build.emptyOutDir` in the vite configuration needs to be `false`.\n\n## Installation\n\n```bash\nnpm i vite-plugin-entries-build-cache -D\n```\n\n```bash\nyarn add vite-plugin-entries-build-cache -D\n```\n\n## Usage\n\nRegister it as a Vite plugin:\n\n```js\n// vite.config.js\nimport entriesBuildCache from 'vite-plugin-entries-build-cache'\nimport { resolve } from 'path'\n\nexport default {\n  plugins: [\n    entriesBuildCache({\n      entryRootPath: resolve(process.cwd(), './src/pages')\n    })\n  ]\n}\n```\n\n## Configuration\n\n| Parameter Name: Type           | Default Value   | Description                                                   |\n| ------------------------------ | --------------- | ------------------------------------------------------------- |\n| `entryRootPath: string`        | -               | The parent folder path of the multi-entry folder              |\n| `rootPath?: string`            | `process.cwd()` | Project root path                                             |\n| `exclude?: string[]`           | `[]`            | Additional exclude files, .gitignore data will always be used |\n| `debug?: boolean`              | `false`         | Whether to show debug logs                                    |\n\nAttention: Correctly configuring the `exclude` parameter can effectively reduce the file diff time. Because the plugin is diffing all files under `rootPath`, not relying on `git`, so if there are a large number of files under `rootPath` and these files will not affect the entry files, such as `package-lock.json`, then these files can be configured to `exclude` to reduce diff time.\n\n## Example\n\n### Project Structure\n\n```bash\n├── src\n│   ├── components\n│   ├── pages\n│   │   ├── index\n│   │   │   ├── index.html\n│   │   │   ├── main.ts\n│   │   │   └── index.vue\n│   └── └── about\n│           ├── index.html\n│           ├── main.ts\n│           └── index.vue\n├── .gitignore\n├── vite.config.js\n├── package-lock.json\n└── package.json\n```\n\n### Vite Config\n\n```js\n// vite.config.js\nimport entriesBuildCache from 'vite-plugin-entries-build-cache'\nimport { defineConfig } from 'vite'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n  plugins: [\n    entriesBuildCache({\n      entryRootPath: resolve(process.cwd(), './src/pages'), // The parent folder path of the multi-entry folder. The plugin will filter the input entry based on the file changes under this path\n      rootPath: process.cwd(), // Project root path\n      exclude: ['.gitignore', 'package-lock.json']\n    })\n  ],\n  build: {\n    emptyOutDir: false, // This configuration needs to be false\n    rollupOptions: {\n      input: {\n        index: resolve(process.cwd(), './src/pages/index/index.html'),\n        about: resolve(process.cwd(), './src/pages/about/index.html')\n      }\n    }\n  }\n})\n```\n\n### Modify Code\n\n1. When editing the file under `entryRootPath` that is `./src/pages`, the filter mechanism will be triggered:\n\n```bash\nmodified:   src/pages/about/index.html\n```\n\nWhen building, only the entry under the changed directory will be packaged, that is, the `about` entry, which is equivalent to:\n\n\n```text\ninput: {\n  about: resolve(process.cwd(), './src/pages/about/index.html')\n}\n```\n\n1. When editing the file in `rootPath`, but not in `entryRootPath`, the filter mechanism will not be triggered:\n\n```bash\nmodified:   vite.config.js\n```\n\nWhen building, all entry files will be packaged, because the plugin cannot determine which entry files will be affected by the changes:\n\n```text\ninput: {\n  index: resolve(process.cwd(), './src/pages/index/index.html'),\n  about: resolve(process.cwd(), './src/pages/about/index.html')\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimmzl%2Fvite-plugin-entries-build-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimmzl%2Fvite-plugin-entries-build-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimmzl%2Fvite-plugin-entries-build-cache/lists"}