vike icon indicating copy to clipboard operation
vike copied to clipboard

run transformIndexHtml in prerender

Open nitedani opened this issue 1 year ago • 3 comments

I'm not sure we should do it like this, what do you think? Maybe it's not ok to call plugin.transformIndexHtml outside of vite.. But if the vite build and prerender runs in the same process, maybe we can bind the function to the vite instance.

nitedani avatar Jun 07 '24 11:06 nitedani

I actually wonder: what's the official way of applying transformIndexHtml() at bulid-time? How do other frameworks do it? Little utility to grep into all Vite-based frameworks: https://github.com/brillout/vite-frameworks.

Btw. let's move the test from /examples/react-full/ to /test/misc/: I'm trying to minimize the amount of E2E tests and I'm using /test/misc/ to test all kinds of things.

brillout avatar Jun 07 '24 11:06 brillout

I've checked and they don't seem to support this. They don't call transformIndexHtml at all. To make it work, there is a custom implementation for vite-pwa for every supported framework: https://github.com/vite-pwa

So, maybe Vike should have one too?

nitedani avatar Jun 16 '24 13:06 nitedani

Does it work with vite-plugin-pwa? If it does then I think it's worth it to do that hack and continue working on this PR.

So, maybe Vike should have one too?

Yes, we could eventually have an extension vike-pwa that modifies the HTML. We can create a new Vike built-in hook for it. But let's do it in a separate PR and later as I don't think it's a priority for now (especially if we do end up merging this PR).

brillout avatar Jun 26 '24 11:06 brillout

With +middleware and the ability for Vike extensions to add Vite plugins, we can create vike-pwa instead of doing this. Let's close in favor of creating vike-pwa.

brillout avatar Sep 06 '24 11:09 brillout