regl-scatterplot icon indicating copy to clipboard operation
regl-scatterplot copied to clipboard

vite auto-refresh

Open manzt opened this issue 2 years ago • 3 comments

Normally vite handles a request for index.html, but vite-plugin-virtual-html-template intercepts requests for .html and doesn't allow vite to inject a runtime client to handle auto-refreshing.

This PR adds a minimal plugin to inject the /@vite/client code during dev and force and auto-refresh. It's not perfect, but it's better than the existing solution.

manzt avatar Jul 13 '21 17:07 manzt

Thanks for the PR! I wonder, does Vite not like the template approach? Maybe we should restructure the examples to have better support by Vite? Right now it feels like we replaced a stable working dev setup with a fast but brittle solution. Don't get me wrong, I like the speediness of Vite but with Webpack everything just worked without any special setups.

Unfortunately, I don't have much experience with Vite but I'll poke around a little tonight.

flekschas avatar Jul 13 '21 20:07 flekschas

I wonder, does Vite not like the template approach?

Yeah this is the primary "issue". Vite out of the box assumes 1:1 mapping of files on disk to your app entry points. Plugins can help with some of this, but plugin ecosystem is young.

Maybe we should restructure the examples to have better support by Vite?

I thought about this as well, but the issue is that we really do want a template of some type for the examples. Making vite (without any plugins) work nicely would entail creating separate x.html.

Unfortunately, I don't have much experience with Vite but I'll poke around a little tonight.

Have a look at my latest changes and let me know what you think. I don't mind reverting if that is your preference!

manzt avatar Jul 13 '21 21:07 manzt

Hmm really odd error in the CI. I tried to track I down earlier to no avail..

manzt avatar Jul 14 '21 22:07 manzt