From f8ebd2e108c8269ed940c289964ec06c80894b0d Mon Sep 17 00:00:00 2001 From: harlan Date: Mon, 27 Jan 2025 22:45:18 +1100 Subject: [PATCH] fix: nitro v3 support --- src/prerender.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/prerender.ts b/src/prerender.ts index c3331f5f..c4c62140 100644 --- a/src/prerender.ts +++ b/src/prerender.ts @@ -6,7 +6,6 @@ import type { Nuxt } from '@nuxt/schema' import type { Nitro, PrerenderRoute } from 'nitropack' import chalk from 'chalk' import { dirname } from 'pathe' -import { build } from 'nitropack' import { defu } from 'defu' import type { ConsolaInstance } from 'consola' import { extractSitemapMetaFromHtml } from './util/extractSitemapMetaFromHtml' @@ -90,8 +89,19 @@ export function setupPrerenderHandler(_options: { runtimeConfig: ModuleRuntimeCo }), route._sitemap) as SitemapUrl }) nitro.hooks.hook('prerender:done', async () => { + const isNuxt4 = nuxt.options._majorVersion === 4 + let nitroModule + if (isNuxt4) { + nitroModule = await import(String('nitro')) + } + else { + nitroModule = await import(String('nitropack')) + } + if (!nitroModule) { + return + } // force templates to be rebuilt - await build(prerenderer) + await nitroModule.build(prerenderer) const routes: string[] = [] if (options.debug)