fix(nuxt): improve default prerender behaviour (#21817)

This commit is contained in:
Daniel Roe 2023-06-28 15:17:19 +01:00 committed by GitHub
parent e023c06353
commit b108b1ee70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { existsSync, promises as fsp, readFileSync } from 'node:fs' import { existsSync, promises as fsp, readFileSync } from 'node:fs'
import { cpus } from 'node:os'
import { join, relative, resolve } from 'pathe' import { join, relative, resolve } from 'pathe'
import { build, copyPublicAssets, createDevServer, createNitro, prepare, prerender, scanHandlers, writeTypes } from 'nitropack' import { build, copyPublicAssets, createDevServer, createNitro, prepare, prerender, scanHandlers, writeTypes } from 'nitropack'
import type { Nitro, NitroConfig } from 'nitropack' import type { Nitro, NitroConfig } from 'nitropack'
@ -131,6 +132,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
.map(dir => ({ dir })) .map(dir => ({ dir }))
], ],
prerender: { prerender: {
failOnError: true,
concurrency: cpus().length * 4 || 4,
crawlLinks: nuxt.options._generate ?? undefined, crawlLinks: nuxt.options._generate ?? undefined,
routes: ([] as string[]) routes: ([] as string[])
.concat(nuxt.options.generate.routes) .concat(nuxt.options.generate.routes)