mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +00:00
fix(vite): warmup server entries with ssr
condition (#6649)
This commit is contained in:
parent
dae836a81d
commit
58c4753ed4
@ -3,7 +3,8 @@ import type { ViteDevServer } from 'vite'
|
|||||||
|
|
||||||
export async function warmupViteServer (
|
export async function warmupViteServer (
|
||||||
server: ViteDevServer,
|
server: ViteDevServer,
|
||||||
entries: string[]
|
entries: string[],
|
||||||
|
isServer: boolean
|
||||||
) {
|
) {
|
||||||
const warmedUrls = new Set<String>()
|
const warmedUrls = new Set<String>()
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export async function warmupViteServer (
|
|||||||
}
|
}
|
||||||
warmedUrls.add(url)
|
warmedUrls.add(url)
|
||||||
try {
|
try {
|
||||||
await server.transformRequest(url)
|
await server.transformRequest(url, { ssr: isServer })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.debug('Warmup for %s failed with: %s', url, e)
|
logger.debug('Warmup for %s failed with: %s', url, e)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
|
|
||||||
if (nuxt.options.vite.warmupEntry !== false) {
|
if (nuxt.options.vite.warmupEntry !== false) {
|
||||||
const start = Date.now()
|
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`))
|
.then(() => logger.info(`Vite ${env.isClient ? 'client' : 'server'} warmed up in ${Date.now() - start}ms`))
|
||||||
.catch(logger.error)
|
.catch(logger.error)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user