-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildEnd not trigger with vite 5.0.10 #15418
Comments
|
why |
Hi @userquin, yeah that what i thought, buildEnd is trigger in build mode but shouldn't be trigger in dev mode.. but it does in Vite 4.5.1. Do you know if there is a similar hook working in dev ? |
No, but you can try adding build hooks (https://rollupjs.org/plugin-development/ and https://vitejs.dev/guide/api-plugin#transformindexhtml)... (apply can be also a function) |
Thanks @userquin, I will figure this out. Should I rename the issue about the buildEnd triggered in dev in Vite 4.5.1 ? |
|
I took a look, and it seemed to work in Vite 4 because we took control of Ctrl+C via We're currently using SIGTERM to listen for process exit, but that only works in controlled environments such as child processes. I tested, and only SIGINT seems to reliably get triggered, but it was removed in a04db16. SIGINT is generally very tricky to work with unfortunately. You need to call This SO answer has some more details. If we do something similar, it might also help lessen the impact of #9470 |
@bluwy the plugin shouldn't be called in EDIT: I think I have misunderstood the issue |
I don't see the plugin running when running |
Hi, @bluwy thanks for the heads up and explaination ! I will wait to see if a fix is push to migrate to Vite 5 ! Thanks ;) |
Maybe we can try |
the custom plugin to end the build correctly from this stackoverflow thread helped me to finally use vite 5 in my deployment workflow... // file vite-plugin-close.ts
export default function ClosePlugin() {
return {
name: 'ClosePlugin', // required, will show up in warnings and errors
// use this to catch errors when building
buildEnd(error) {
if(error) {
console.error('Error bundling')
console.error(error)
process.exit(1)
} else {
console.log('Build ended')
}
},
// use this to catch the end of a build without errors
closeBundle(id) {
console.log('Bundle closed')
process.exit(0)
},
}
} // file vite.config.ts
import ClosePlugin from './vite-plugin-close.ts'
// ...
// place the plugin in the *vite* plugins section
// NOT the rollupOptions.plugins section
plugins: [ClosePlugin()], |
Describe the bug
Hi,
It seems that buildEnd hook is not trigger anymore in vite 5.0.10 with a custom plugin. I run
npm run dev
then ctl-c to exit the process and buildEnd isn't trigger.I tried with vite 4.5.1 and it works.
For the reproduction, I created a small plugin to test it on stackblitz ! It should console.log buildStart then buildEnd when the process is exited.
Thanks for the great work btw !
Reproduction
https://stackblitz.com/edit/vitejs-vite-8cekfx?file=vite.config.js
Steps to reproduce
npm install && npm run dev
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: