fix(vite): warmup server entries with ssr condition (#6649)

This commit is contained in:
pooya parsa 2022-08-15 18:03:00 +02:00 committed by GitHub
parent dae836a81d
commit 58c4753ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -3,7 +3,8 @@ import type { ViteDevServer } from 'vite'
export async function warmupViteServer (
server: ViteDevServer,
entries: string[]
entries: string[],
isServer: boolean
) {
const warmedUrls = new Set<String>()
@ -13,7 +14,7 @@ export async function warmupViteServer (
}
warmedUrls.add(url)
try {
await server.transformRequest(url)
await server.transformRequest(url, { ssr: isServer })
} catch (e) {
logger.debug('Warmup for %s failed with: %s', url, e)
}

View File

@ -103,7 +103,7 @@ export async function bundle (nuxt: Nuxt) {
if (nuxt.options.vite.warmupEntry !== false) {
const start = Date.now()
warmupViteServer(server, [join('/@fs/', ctx.entry)])
warmupViteServer(server, [join('/@fs/', ctx.entry)], env.isServer)
.then(() => logger.info(`Vite ${env.isClient ? 'client' : 'server'} warmed up in ${Date.now() - start}ms`))
.catch(logger.error)
}