mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): handle injecting multiple entry ids for styles (#21864)
This commit is contained in:
parent
5f5b9dfe99
commit
87e01ccf0e
@ -66,7 +66,10 @@ const getClientManifest: () => Promise<Manifest> = () => import('#build/dist/ser
|
||||
.then(r => r.default || r)
|
||||
.then(r => typeof r === 'function' ? r() : r) as Promise<ClientManifest>
|
||||
|
||||
const getEntryId: () => Promise<string> = () => getClientManifest().then(r => Object.values(r).find(r => r.isEntry)!.src!)
|
||||
const getEntryIds: () => Promise<string[]> = () => getClientManifest().then(r => Object.values(r).filter(r =>
|
||||
// @ts-expect-error internal key set by CSS inlining configuration
|
||||
r._globalCSS
|
||||
).map(r => r.src!))
|
||||
|
||||
// @ts-expect-error virtual file
|
||||
const getStaticRenderedHead = (): Promise<NuxtMeta> => import('#head-static').then(r => r.default || r)
|
||||
@ -289,11 +292,11 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
|
||||
const renderedMeta = await ssrContext.renderMeta?.() ?? {}
|
||||
|
||||
if (process.env.NUXT_INLINE_STYLES && !islandContext) {
|
||||
const entryId = await getEntryId()
|
||||
if (ssrContext.modules) {
|
||||
ssrContext.modules.add(entryId)
|
||||
} else if (ssrContext._registeredComponents) {
|
||||
ssrContext._registeredComponents.add(entryId)
|
||||
const source = ssrContext.modules ?? ssrContext._registeredComponents
|
||||
if (source) {
|
||||
for (const id of await getEntryIds()) {
|
||||
source.add(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,10 @@ export async function bundle (nuxt: Nuxt) {
|
||||
for (const key in manifest) {
|
||||
const entry = manifest[key]
|
||||
const shouldRemoveCSS = chunksWithInlinedCSS.has(key) && !entry.isEntry
|
||||
if (entry.isEntry && chunksWithInlinedCSS.has(key)) {
|
||||
// @ts-expect-error internal key
|
||||
entry._globalCSS = true
|
||||
}
|
||||
if (shouldRemoveCSS && entry.css) {
|
||||
entry.css = []
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user