Skip to content

Commit

Permalink
fix: nitro v3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jan 27, 2025
1 parent 006471f commit f8ebd2e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f8ebd2e

Please sign in to comment.