How to handle outdated lazy loaded routes chunk name changes when routing #247
-
Hi all, When lazy loading chunks, in a spa, if the route has not yet been navigated to and server side a new build gets deployed, the chunk name that will be routed to no longer exists on the server, so there is a 404? e.g.
Is there an inbuilt way to handle this? Or Am I able to hook some code into catching this error and manually work out what the new chunk should be via some hand crafted method (e.g. load the latest manifest.json from the server and ask it for the new Hopefully I have just missed something simple :) Thanks in advanced 👍 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello! This is because fo chunks names, it's at the bundler level. With Vue Router, you can hook into the This allows you to reload the page so the browser fetches the new js assets |
Beta Was this translation helpful? Give feedback.
Hello! This is because fo chunks names, it's at the bundler level. With Vue Router, you can hook into the
router.onError()
: vitejs/vite#11804 (comment)This allows you to reload the page so the browser fetches the new js assets