mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
chore: router improvements (#139)
This commit is contained in:
parent
9be282623c
commit
b04e212ebc
6
packages/nuxt3/src/app/pages/404.vue
Normal file
6
packages/nuxt3/src/app/pages/404.vue
Normal file
@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- TODO: Move this page to @nuxt/nice -->
|
||||
404 | Page Not Found
|
||||
</div>
|
||||
</template>
|
@ -13,11 +13,6 @@ import routes from '~build/routes'
|
||||
export default <Plugin> function router (nuxt) {
|
||||
const { app } = nuxt
|
||||
|
||||
// TODO: move this outside this plugin
|
||||
if (!routes.length) {
|
||||
return
|
||||
}
|
||||
|
||||
app.component('NuxtPage', NuxtPage)
|
||||
app.component('NuxtLink', RouterLink)
|
||||
|
||||
|
@ -43,6 +43,16 @@ export async function createApp (
|
||||
if (app.pages) {
|
||||
app.routes.push(...(await resolvePagesRoutes(builder, app)))
|
||||
}
|
||||
// Add 404 page is not added
|
||||
const page404 = app.routes.find(route => route.name === '404')
|
||||
if (!page404) {
|
||||
app.routes.push({
|
||||
name: '404',
|
||||
path: '/:catchAll(.*)*',
|
||||
file: resolve(nuxt.options.appDir, 'pages/404.vue'),
|
||||
children: []
|
||||
})
|
||||
}
|
||||
// TODO: Hook to extend routes
|
||||
app.templates.routes = serializeRoutes(app.routes)
|
||||
|
||||
@ -69,7 +79,7 @@ function formatRoute (route: NuxtRoute) {
|
||||
name: route.name,
|
||||
path: route.path,
|
||||
children: route.children.map(formatRoute),
|
||||
// TODO: avoid exposing to prod
|
||||
// TODO: avoid exposing to prod, using process.env.NODE_ENV ?
|
||||
__file: route.file,
|
||||
component: `{() => import('${route.file}' /* webpackChunkName: '${route.name}' */)}`
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ function normalizeConfig (_options: CliConfiguration) {
|
||||
|
||||
// Append ignorePrefix glob to ignore
|
||||
if (typeof options.ignorePrefix === 'string') {
|
||||
options.ignore.push(`**/${options.ignorePrefix}*.*`)
|
||||
options.ignore.push(`${options.ignorePrefix}*`)
|
||||
}
|
||||
|
||||
// Compression middleware legacy
|
||||
|
Loading…
Reference in New Issue
Block a user