Skip to content

Commit 064cf49

Browse files
committed
fix: use app:resolve for latest possible exclusion of vue router
1 parent a7f8ab4 commit 064cf49

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

src/parts/router.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,32 @@ export const setupRouter = () => {
2525
nuxt.options.vite.optimizeDeps.include = nuxt.options.vite.optimizeDeps.include || []
2626
nuxt.options.vite.optimizeDeps.include.push('@ionic/vue-router')
2727

28-
nuxt.hook('modules:done', () => {
29-
nuxt.options.plugins = nuxt.options.plugins.filter(
30-
p =>
31-
!(typeof p === 'string' ? p : p.src).endsWith('nuxt/dist/pages/runtime/router') &&
32-
!(typeof p === 'string' ? p : p.src).endsWith('nuxt/dist/app/plugins/router')
28+
nuxt.hook('app:resolve', app => {
29+
app.plugins = app.plugins.filter(
30+
p => !p.src.match(/nuxt3?\/dist\/(app\/plugins|pages\/runtime)\/router/)
3331
)
32+
})
3433

35-
// Add all pages to be prerendered
36-
const routes: string[] = []
34+
// Add all pages to be prerendered
35+
const routes: string[] = []
3736

38-
nuxt.hook('pages:extend', pages => {
39-
routes.length = 0
40-
routes.push('/', ...((nuxt.options.nitro.prerender?.routes || []) as string[]))
41-
function processPages(pages: NuxtPage[], currentPath = '') {
42-
for (const page of pages) {
43-
if (page.path.includes(':')) continue
37+
nuxt.hook('pages:extend', pages => {
38+
routes.length = 0
39+
routes.push('/', ...((nuxt.options.nitro.prerender?.routes || []) as string[]))
40+
function processPages(pages: NuxtPage[], currentPath = '') {
41+
for (const page of pages) {
42+
if (page.path.includes(':')) continue
4443

45-
const path = joinURL(currentPath, page.path)
46-
routes.push(path)
47-
if (page.children) processPages(page.children, path)
48-
}
44+
const path = joinURL(currentPath, page.path)
45+
routes.push(path)
46+
if (page.children) processPages(page.children, path)
4947
}
50-
processPages(pages)
51-
})
48+
}
49+
processPages(pages)
50+
})
5251

53-
nuxt.hook('nitro:build:before', nitro => {
54-
nitro.options.prerender.routes = routes
55-
})
52+
nuxt.hook('nitro:build:before', nitro => {
53+
nitro.options.prerender.routes = routes
5654
})
5755

5856
// Remove vue-router types

0 commit comments

Comments
 (0)