mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(nuxt): use native vue-router composables (#28114)
This commit is contained in:
parent
200fe48829
commit
4ea89318df
@ -223,6 +223,14 @@ export default defineNuxtModule({
|
||||
references.push({ types: useExperimentalTypedPages ? 'vue-router/auto-routes' : 'vue-router' })
|
||||
})
|
||||
|
||||
// Add vue-router route guard imports
|
||||
nuxt.hook('imports:sources', (sources) => {
|
||||
const routerImports = sources.find(s => s.from === '#app/composables/router' && s.imports.includes('onBeforeRouteLeave'))
|
||||
if (routerImports) {
|
||||
routerImports.from = 'vue-router'
|
||||
}
|
||||
})
|
||||
|
||||
// Regenerate templates when adding or removing pages
|
||||
const updateTemplatePaths = nuxt.options._layers.flatMap((l) => {
|
||||
const dir = (l.config.rootDir === nuxt.options.rootDir ? nuxt.options : l.config).dir
|
||||
|
Loading…
Reference in New Issue
Block a user