Skip to content

Commit

Permalink
Reload on all chunks, not just routes (as per nuxt/nuxt#19086 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed May 18, 2023
1 parent b89fb9a commit 695e0a8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions plugins/chunks.client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as Sentry from '@sentry/browser'
import { useRoute } from 'vue-router'
import { defineNuxtPlugin } from '#app/nuxt'
import { reloadNuxtApp } from '#app/composables/chunk'

export default defineNuxtPlugin({
setup(nuxtApp) {
const route = useRoute()

nuxtApp.hook('app:chunkError', ({ error }) => {
Sentry.captureMessage(
'Caught chunk error in ' +
route.path +
', will reload: ' +
JSON.stringify(error)
)

reloadNuxtApp({ path: route.path, persistState: true })
})
},
})

0 comments on commit 695e0a8

Please sign in to comment.