sapphi-red / vite-plugin-static-copy

rollup-plugin-copy with dev server support.
MIT License
287 stars 31 forks source link

Feature: Allow users to specify hook for when plugin is ran #132

Open rschristian opened 6 days ago

rschristian commented 6 days ago

Is there any interest in allowing users to configure when the plugin is ran? While this plugin certainly does some things differently, rollup-plugin-copy has a similar option to set the hook which would be nice to have.

Unfortunately I need this plugin to run earlier, during generateBundle, so I've taken to patching this line across a couple dozen or so projects:

https://github.com/sapphi-red/vite-plugin-static-copy/blob/c3a14747adf4edb45d2270f0fe3a8dfe551e0a12/src/build.ts#L23

Happy to keep patching if need be, but thought I'd ask.

sapphi-red commented 3 days ago

May I ask a bit more in detail why you need to run this plugin during generateBundle?

rschristian commented 3 days ago

Some other plugins need that content to be transformed and written to the disk by the time they run, and, as far as I know, there's no way to guarantee that besides moving this plugin forward a stage. Moving an FS operation forward, to my knowledge, wouldn't cause any issues either (besides potential name collisions/overwrites I suppose) which is why it seemed like the better target for a patch.

sapphi-red commented 3 days ago

I see. I'm open to add this feature. PR welcome 🙂