Run a plugin once another plugin has finished processing all the files in the transform hook? #19380
Replies: 5 comments 2 replies
-
This feels too specific to have in Vite core. If the two plugins are so tightly coupled, I think they should communicate directly, not through some mechanism provided by Vite. |
Beta Was this translation helpful? Give feedback.
-
but how will they communicate? since plugin2 needs to start transforming only when plugin1 has finished transforming all the files? I would've run both plugins one after the other in the same transform hook for each file if the above were not the case. @sapphi-red |
Beta Was this translation helpful? Give feedback.
-
How do you know when the master plugin has finished processing all the files? Instead using vite plugins, why not just add some minimal post-process interface to the plugin? Once the plugin finish the pre-processing in all targets it can just call all registered post-processes: these post-processes can be from user lang or registered from other vite plugins via Rollup direct communication api ( https://rollupjs.org/plugin-development/#direct-plugin-communication ), the plugin should expose the api to register the post-process entries. |
Beta Was this translation helpful? Give feedback.
-
I thought you know all the file names that plugin1 needs to process. But it seems you don't know it? In that case, there's no way to know all the file names automatically. |
Beta Was this translation helpful? Give feedback.
-
Thx for the link |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm running a plugin in the transform hook that transforms all files and gathers some intel on the CSS styles that are used in the code; based on the intel, I need to transform all the files again. But I'm not able to find a way to process all the files again with another plugin once the previous plugin has finished transforming all the files in the transform hook.
Here is the plugin: plugin, I'm transforming the files in the transform hook with plugin1 that store some data on the css object, and then once all the files are processed by plugin1, I need to transform those files that were transformed by plugin1 with plugin2. The only way I was able to do this, is in the renderChunk hook, but it doesn't get invoked with the dev server.
Pl help.
Suggested solution
It'd be helpful if we can transform the files in another hook that were transformed with the transform hook.
Alternative
No response
Additional context
No response
Validations
Beta Was this translation helpful? Give feedback.
All reactions