Skip to content
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

Add a writeBundle or buildEnd hook #880

Closed
JonasKruckenberg opened this issue Oct 5, 2020 · 1 comment · Fixed by #957
Closed

Add a writeBundle or buildEnd hook #880

JonasKruckenberg opened this issue Oct 5, 2020 · 1 comment · Fixed by #957

Comments

@JonasKruckenberg
Copy link

JonasKruckenberg commented Oct 5, 2020

Is your feature request related to a problem? Please describe.
A good number of rollup plugins use the writeBundle hook, to run tools after all chunks and assets have been emitted, this hook however is never called with the vite build system since instead of using rollups bundle.write method it uses its own.

Describe the solution you'd like
My suggestion would be to either call the writeBundle hook on all rollup plugins manually or implement a custom hook in the vite plugin interface that gets called after all assets have been written to disk.
Describe alternatives you've considered
There is not really a workaround with rollup, you could try to detect filesystem changes manually or something I guess...
You can run any script after vite build has finished but that is really awkward, requiring placeholder scripts in the public folder, I think we can do better than that.

Additional context
Would solve #853 as then rollup-plugin-workbox would work again.

It really should not be a big issue, if you want I can create a pull request for it!

@dominikg
Copy link
Contributor

dominikg commented Oct 8, 2020

rollup docs for writeBundle start with "If it is called". So it is not mandatory to call it. rollup-plugin-workbox could try to use generatebundle instead.

I'm not sure you should fake writebundle unless what vite is writing exactly matches what the hook api expects it too. Otherwise you get lots of compatibility issues

underfin added a commit to rolldown/vite that referenced this issue Oct 26, 2020
1. generate asset by `emitFile` and format file name by rollup options.
2. use `rollup.write` instead of `rollup.generate`, let many rollup plugins can work with `writeBundle` hook.

fix vitejs#880, fix vitejs#912, fix vitejs#378
yyx990803 pushed a commit that referenced this issue Oct 26, 2020
1. generate asset by `emitFile` and format file name by rollup options.
2. use `rollup.write` instead of `rollup.generate`, let many rollup plugins can work with `writeBundle` hook.

fix #880, fix #912, fix #378
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants