Open yanniznik opened 7 months ago
A workaround can be used in nuxt.config.ts
with:
router: {
extendRoutes(routes, resolve) {
routes.unshift({
path: '/newRoute',
component: resolve('aVueComponent.vue'),
})
}
}
instead of using extendPage
which is not working at the moment.
For nuxt 2, build:extendRoutes
is called.
https://github.com/nuxt/nuxt/blob/main/packages/kit/src/pages.ts#L13
Therefore, component
should be used instead of file
.
extendPages((pages, resolve) => {
pages.unshift({
path: '/locale',
- file: resolver.resolve('../Locale/Locale.vue'),
+ component: resolver.resolve('../Locale/Locale.vue'),
});
});
Environment
Darwin
v18.18.2
2.17.3
3.10.0
2.8.1
yarn@1.22.19
webpack
bridge
,modules
,serverHandlers
,devServerHandlers
,devServer
,typescript
,nitro
,buildModules
@/modules/addLocale.ts
()
,@nuxt/bridge@3.0.1-28459804.a0dceb3
Reproduction
Stackblitz: https://stackblitz.com/edit/github-nafqpn?file=modules%2FaddLocale.ts Repo: https://github.com/yanniznik/nuxt-bridge-extendPages
modules
yarn dev
$nuxt.$router.options.routes
/Locale
and get 404 instead of componentDescribe the bug
Current: The page doesn't load (404 not found). The new "/Locale" route was added from a module using
extendPage
. Looking at the route object clearly shows that the route doesn't have acomponent
attachedExpected: the
component
is attached to the route so that it can be loaded normallyAdditional context
The exact same setu in Nuxt3 works.
/Locale
is apccessible Example stablitz with Nuxt3, same setup: https://stackblitz.com/github/nuxt/examples/tree/main/examples/advanced/module-extend-pages?embed=1&file=pages/index.vue&theme=darkLogs
No response