Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dishait/vite-plugin-builded-force-exit
vite 打包后强制退出的插件
https://github.com/dishait/vite-plugin-builded-force-exit
build exit force plugin vite
Last synced: about 1 month ago
JSON representation
vite 打包后强制退出的插件
- Host: GitHub
- URL: https://github.com/dishait/vite-plugin-builded-force-exit
- Owner: dishait
- License: mit
- Created: 2022-02-11T06:04:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-28T08:46:39.000Z (10 months ago)
- Last Synced: 2024-11-13T02:49:08.418Z (about 2 months ago)
- Topics: build, exit, force, plugin, vite
- Language: TypeScript
- Homepage:
- Size: 84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-builded-force-exit
`vite` 打包后强制退出的插件
## 动机 🐇
在开发环境下,我们可能会在 `vite` 之外去注册一些监听,这些监听会让进程持续运行,例如 `chokidar` 的文件监听。
但是在 `vite` 的生产打包过程中如果不去手动移除所有的监听,会让整个进程持续进行着,即使打包已经完成了。
## 注意事项 👀
如果你有使用 `build` 模式即构建时的插件,那么你可能应该考虑使用其本身所暴露的配置
例如 [vite-plugin-compression](https://github.com/vbenjs/vite-plugin-compression) 👇
```ts
import { defineConfig } from 'vite'
import Compression from 'vite-plugin-compression'export default defineConfig({
plugins: [
Compression({
// 成功后强制,退出进程
success() {
setImmediate(process.exit)
}
})
]
})
```
## 使用 🦕
### 安装
```shell
pnpm i vite-plugin-builded-force-exit// 或者 npm i vite-plugin-builded-force-exit
// 或者 yarn add vite-plugin-builded-force-exit
```
### 配置
```ts
// vite.config.ts
// 或者 vite.config.jsimport { defineConfig } from 'vite'
import BuildedForceExit from 'vite-plugin-builded-force-exit'export default defineConfig({
plugins: [
// ...
BuildedForceExit()
]
})
```
### 延迟退出
设置 `delay` 即可,单位为毫秒,类型为 `number`。
```ts
// vite.config.ts
// 或者 vite.config.jsimport { defineConfig } from 'vite'
import BuildedForceExit from 'vite-plugin-builded-force-exit'export default defineConfig({
plugins: [
// ...
BuildedForceExit({
delay: 5000 // 5秒后退出
})
]
})
```
## License
Made with markthree
Published under [MIT License](./LICENSE).