-
-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial flashing of index route on page load (when another route is requested) #159
Comments
SSG seem to broken, investigating. |
Looks like it's mainly because PWA is serving the wrong file, /cc @userquin do you have any idea on how could we make PWA aware of the url prettify? |
@antfu The problem is that routes are not included in the sw manifest, and so the router will get the If you look at the I'm looking for a way to map routers to logical names and include them into the sw manifest: In my projects I include them manually. |
@antfu I have it working, we need to do some changes to track routes using EDIT: my branch is to show you how to solve the problem, it is a trick to make it working, I would like to modify The changes are on The problem is that each time the project is built the sw is updated: since the sw is generated on client generation from On my projects I build the revision this way. |
@antfu maybe we can change the order on I don't know if we can access to vite configuration (from For example, generating client last on export interface ViteSSGOptions {
...
generateRouteAndRevision?: boolean // <== if generating for passing them to onFinished
onFinished?: (routesUrlAndRevisions: Map<string, string>) => void // <== can be a Record<string, string>
} In this scenario we'll have this: // vite.config.ts
const pwaRouterManifestEntries: any[] = []
export default defineConfig({
...
...
plugins: [
...
...
VitePWA({
...
workbox: {
additionalManifestEntries: pwaRouterManifestEntries,
},
// or
injectManifest: {
additionalManifestEntries: pwaRouterManifestEntries,
},
}),
...
],
...
...
ssgOptions: {
script: 'async',
formatting: 'minify',
generateRouteAndRevision: true,
onFinished(routesUrlAndRevisions) {
// for map
routesUrlAndRevisions.forEach((revision, url) => pwaRouterManifestEntries.push({ url, revision }))
// for record
Object.keys(routesUrlAndRevisions).forEach(url => pwaRouterManifestEntries.push({ url, revision: routesUrlAndRevisions[url] })
}
},
...
...
}) Second option is to add an explicit option such as export interface ViteSSGOptions {
...
onFinished?: () => void
pwaRouterManifestEntries?: any[]
} In this last scenario we can have this: // vite.config.ts
const pwaRouterManifestEntries: any[] = []
export default defineConfig({
...
...
plugins: [
...
...
VitePWA({
...
workbox: {
additionalManifestEntries: pwaRouterManifestEntries,
},
// or
injectManifest: {
additionalManifestEntries: pwaRouterManifestEntries,
},
}),
...
],
...
...
ssgOptions: {
script: 'async',
formatting: 'minify',
pwaRouterManifestEntries,
},
...
...
}) In both cases, we need to mofify the logic on I like the second approach, what do you think? |
@userquin thanks for the detailed explanation. Let me take some time to think about how to have them work together properly. |
@antfu we cannot move client generation to last step since we need the ssr manifest: it is also generated on client build step. |
@antfu I have an entry on vite about handling I also mention this problem on i18n router discussion entry on vite-ssg, since we have a spa we need to generate also client manifest to extract non index page dependencies to be injected on generated html page. For dynamic page entries I think we need to find a way on client side to make page transition smooth while resolving initial router transition. |
The link for vite-ssg |
Hi! Looks like this issue is back. Please observe the initial load for this page: https://vitesse.netlify.app/hi/something You will see the index page flashing for a split second |
It is not back, this page is dynamic and so excluded by default from ssg, I wrote about it on discussions a few months ago. I am checking how to solve this problem. |
Hi!
When you open the app with a different route than index (as its seen in /about below), there is a split second of index route flashing. Happens both on static and dynamic routes.
You can observe this behaviour (although it's very quick) on the official example behaviour as well:
https://vitesse.netlify.app/about
or
https://vitesse.netlify.app/hi/something
Is this the expected behaviour? Is there a way to avoid this, even if that means a slower initial page load?
Thank you!
The text was updated successfully, but these errors were encountered: