fix(nuxt): don't force prerender / if user doesn't have that route (#8639)

* fix(nuxt): don't force prerender `/` if user doesn't have `~/pages/index.vue`

* docs: add code comment
This commit is contained in:
Daniel Roe 2022-11-03 10:52:03 -04:00 committed by GitHub
parent 496fa14468
commit 71ecffa234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,6 +102,9 @@ export default defineNuxtModule({
}) })
nuxt.hook('nitro:build:before', (nitro) => { nuxt.hook('nitro:build:before', (nitro) => {
for (const route of nitro.options.prerender.routes || []) { for (const route of nitro.options.prerender.routes || []) {
// Skip default route value as we only generate it if it is already
// in the detected routes from `~/pages`.
if (route === '/') { continue }
prerenderRoutes.add(route) prerenderRoutes.add(route)
} }
nitro.options.prerender.routes = Array.from(prerenderRoutes) nitro.options.prerender.routes = Array.from(prerenderRoutes)