mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): inline entry styles before component styles (#25749)
This commit is contained in:
parent
3ac8b18cb6
commit
795050e68c
@ -299,6 +299,9 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
||||
nuxt: undefined!, /* NuxtApp */
|
||||
payload: (ssrError ? { error: ssrError } : {}) as NuxtPayload,
|
||||
_payloadReducers: {},
|
||||
modules: new Set(),
|
||||
set _registeredComponents(value) { this.modules = value },
|
||||
get _registeredComponents() { return this.modules },
|
||||
islandContext
|
||||
}
|
||||
|
||||
@ -322,6 +325,13 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
||||
writeEarlyHints(event, link)
|
||||
}
|
||||
|
||||
|
||||
if (process.env.NUXT_INLINE_STYLES && !isRenderingIsland) {
|
||||
for (const id of await getEntryIds()) {
|
||||
ssrContext.modules!.add(id)
|
||||
}
|
||||
}
|
||||
|
||||
const _rendered = await renderer.renderToString(ssrContext).catch(async (error) => {
|
||||
// We use error to bypass full render if we have an early response we can make
|
||||
if (ssrContext._renderResponse && error.message === 'skipping render') { return {} as ReturnType<typeof renderer['renderToString']> }
|
||||
@ -356,18 +366,9 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
||||
await payloadCache!.setItem(withoutTrailingSlash(url), renderPayloadResponse(ssrContext))
|
||||
}
|
||||
|
||||
if (process.env.NUXT_INLINE_STYLES && !isRenderingIsland) {
|
||||
const source = ssrContext.modules ?? ssrContext._registeredComponents
|
||||
if (source) {
|
||||
for (const id of await getEntryIds()) {
|
||||
source.add(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render inline styles
|
||||
const inlinedStyles = (process.env.NUXT_INLINE_STYLES || isRenderingIsland)
|
||||
? await renderInlineStyles(ssrContext.modules ?? ssrContext._registeredComponents ?? [])
|
||||
? await renderInlineStyles(ssrContext.modules ?? [])
|
||||
: []
|
||||
|
||||
const NO_SCRIPTS = process.env.NUXT_NO_SCRIPTS || routeOptions.experimentalNoScripts
|
||||
|
Loading…
Reference in New Issue
Block a user