-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use plugin for chunk error detection in addition to nuxt built-in
Signed-off-by: Alexander Trost <[email protected]>
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Modified version based on https://github.com/nuxt/nuxt/pull/19086#issuecomment-1553385289 | ||
export default defineNuxtPlugin((nuxtApp) => { | ||
nuxtApp.hook('app:chunkError', ({ error }) => { | ||
const error_list = [ | ||
'error loading dynamically imported module', | ||
'Importing a module script failed', | ||
'Failed to fetch dynamically imported module', | ||
]; | ||
|
||
if (typeof error.message === 'string') | ||
for (const message of error_list) { | ||
if (message.indexOf(error.message) > -1) { | ||
reloadNuxtApp({ persistState: true }); | ||
} | ||
} | ||
}); | ||
}); |
File renamed without changes.