{"id":15065661,"url":"https://github.com/dishait/vite-plugin-builded-force-exit","last_synced_at":"2026-01-03T05:04:46.132Z","repository":{"id":109424554,"uuid":"458065536","full_name":"dishait/vite-plugin-builded-force-exit","owner":"dishait","description":"vite 打包后强制退出的插件","archived":false,"fork":false,"pushed_at":"2024-02-28T08:46:39.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T02:02:13.377Z","etag":null,"topics":["build","exit","force","plugin","vite"],"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/dishait.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":"2022-02-11T06:04:31.000Z","updated_at":"2022-02-12T03:36:18.000Z","dependencies_parsed_at":"2024-09-29T10:40:24.592Z","dependency_job_id":null,"html_url":"https://github.com/dishait/vite-plugin-builded-force-exit","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":"dishait/vite-plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dishait%2Fvite-plugin-builded-force-exit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dishait%2Fvite-plugin-builded-force-exit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dishait%2Fvite-plugin-builded-force-exit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dishait%2Fvite-plugin-builded-force-exit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dishait","download_url":"https://codeload.github.com/dishait/vite-plugin-builded-force-exit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806114,"owners_count":20350783,"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":["build","exit","force","plugin","vite"],"created_at":"2024-09-25T00:44:35.679Z","updated_at":"2026-01-03T05:04:46.081Z","avatar_url":"https://github.com/dishait.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-builded-force-exit\n\n`vite` 打包后强制退出的插件\n\n\u003cbr /\u003e\n\n## 动机 🐇\n\n在开发环境下，我们可能会在 `vite` 之外去注册一些监听，这些监听会让进程持续运行，例如 `chokidar` 的文件监听。  \n但是在 `vite` 的生产打包过程中如果不去手动移除所有的监听，会让整个进程持续进行着，即使打包已经完成了。\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n\n## 注意事项 👀\n\n如果你有使用 `build` 模式即构建时的插件，那么你可能应该考虑使用其本身所暴露的配置\n\n例如 [vite-plugin-compression](https://github.com/vbenjs/vite-plugin-compression) 👇\n\n```ts\nimport { defineConfig } from 'vite'\nimport Compression from 'vite-plugin-compression'\n\nexport default defineConfig({\n    plugins: [\n        Compression({\n            // 成功后强制，退出进程\n            success() {\n                setImmediate(process.exit) \n            }\n        })\n    ]\n})\n```\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## 使用 🦕\n\n### 安装\n\n```shell\npnpm i vite-plugin-builded-force-exit\n\n// 或者 npm i vite-plugin-builded-force-exit\n// 或者 yarn add vite-plugin-builded-force-exit\n```\n\n\u003cbr /\u003e\n\n### 配置\n\n```ts\n// vite.config.ts\n// 或者 vite.config.js\n\nimport { defineConfig } from 'vite'\nimport BuildedForceExit from 'vite-plugin-builded-force-exit'\n\nexport default defineConfig({\n    plugins: [\n        // ...\n        BuildedForceExit()\n    ]\n})\n```\n\n\u003cbr /\u003e\n\n### 延迟退出\n\n设置 `delay` 即可，单位为毫秒，类型为 `number`。\n\n```ts\n// vite.config.ts\n// 或者 vite.config.js\n\nimport { defineConfig } from 'vite'\nimport BuildedForceExit from 'vite-plugin-builded-force-exit'\n\nexport default defineConfig({\n    plugins: [\n        // ...\n        BuildedForceExit({\n            delay: 5000 // 5秒后退出\n        })\n    ]\n})\n```\n\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## License\n\nMade with markthree\n\nPublished under [MIT License](./LICENSE).\n\n\u003cbr /\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdishait%2Fvite-plugin-builded-force-exit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdishait%2Fvite-plugin-builded-force-exit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdishait%2Fvite-plugin-builded-force-exit/lists"}