Skip to content

Commit f8ebd2e

Browse files
committedJan 27, 2025·
fix: nitro v3 support
1 parent 006471f commit f8ebd2e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎src/prerender.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { Nuxt } from '@nuxt/schema'
66
import type { Nitro, PrerenderRoute } from 'nitropack'
77
import chalk from 'chalk'
88
import { dirname } from 'pathe'
9-
import { build } from 'nitropack'
109
import { defu } from 'defu'
1110
import type { ConsolaInstance } from 'consola'
1211
import { extractSitemapMetaFromHtml } from './util/extractSitemapMetaFromHtml'
@@ -90,8 +89,19 @@ export function setupPrerenderHandler(_options: { runtimeConfig: ModuleRuntimeCo
9089
}), route._sitemap) as SitemapUrl
9190
})
9291
nitro.hooks.hook('prerender:done', async () => {
92+
const isNuxt4 = nuxt.options._majorVersion === 4
93+
let nitroModule
94+
if (isNuxt4) {
95+
nitroModule = await import(String('nitro'))
96+
}
97+
else {
98+
nitroModule = await import(String('nitropack'))
99+
}
100+
if (!nitroModule) {
101+
return
102+
}
93103
// force templates to be rebuilt
94-
await build(prerenderer)
104+
await nitroModule.build(prerenderer)
95105

96106
const routes: string[] = []
97107
if (options.debug)

0 commit comments

Comments
 (0)