haifeng2013 / rollup-plugin-bundle-html

MIT License
27 stars 11 forks source link

Use `generateBundle` instead of `onwrite` #4

Closed doktordata closed 5 years ago

doktordata commented 5 years ago

Fix for #3

haifeng2013 commented 5 years ago

@doktordata Thanks for your pr and sorry for the late response. Yes, we need to switch to generateBundle.

however, I believe we cannot simply replace onwrite by generateBundle, as "onwrite" is executed "after the file has been written to disk.", and "generateBundle" is executed " immediately before the files are written in bundle.write()".

And this plugin actually needs to read the generated file on disk and insert it into HTML file.

r0skar commented 5 years ago

I think we should use the writeBundle hook.

Called only at the end of bundle.write() once all files have been written. Similar to the generateBundle hook, bundle provides the full list of files being written along with their details.

haifeng2013 commented 5 years ago

@r0skar you are probably right ;)

haifeng2013 commented 5 years ago

onwrite hook is replaced, close this pr.