prerenderer icon indicating copy to clipboard operation
prerenderer copied to clipboard

Vite + React

Open br0wsa opened this issue 2 years ago • 1 comments

Hello, I'm using the latest version of Vite with React.

I'm encountering this error:

RollupError: index.html not found during prerender and error during build: RollupError: Could not prerender: event 'custom-render-trigger' did not occur within 30s.

I added

yarn add puppeteer
and yarn add ts-deepmerge

which are required but not yet mentioned in the documentation. However, the issue persists.

And from that point onwards, all my routes were prerendered in the "dist" folder. GOOD JOB !

br0wsa avatar Jan 11 '24 19:01 br0wsa

I'm not familiar with react so I don't know what useEffect does, the issue is for sure that the index.html file cannot be found, this file is used to serve your content and load your scripts so you'll need to give more details about your project to debug this

By commenting the renderAfterDocumentEvent it fallbacks to the default mode, which is to render as soon as possible when the page is loaded, without any other check, so your javascript will not have not been executed and since it's a react page it means you likely have a blank page when prerendering (have a look at the prerendered files in notepad) also since index.html was not found prior it likely means it's rendering a 404 page

For the missing dependencies, puppeteer is marked as a peer dependency and there is multiple modes of installation (one using the system browser using puppeteer-core and one downloading it on every install) the download is very big (~200Mo) so we don't force an optional dep this big when you install the package (most people using on CI will load it from cache or from the system) but it's true it's not documented

For ts-deepmerge I will publish an update with the missing dep

Tofandel avatar Jan 12 '24 11:01 Tofandel