mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +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 => r.default || r)
|
||||||
.then(r => typeof r === 'function' ? r() : r) as Promise<ClientManifest>
|
.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
|
// @ts-expect-error virtual file
|
||||||
const getStaticRenderedHead = (): Promise<NuxtMeta> => import('#head-static').then(r => r.default || r)
|
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?.() ?? {}
|
const renderedMeta = await ssrContext.renderMeta?.() ?? {}
|
||||||
|
|
||||||
if (process.env.NUXT_INLINE_STYLES && !islandContext) {
|
if (process.env.NUXT_INLINE_STYLES && !islandContext) {
|
||||||
const entryId = await getEntryId()
|
const source = ssrContext.modules ?? ssrContext._registeredComponents
|
||||||
if (ssrContext.modules) {
|
if (source) {
|
||||||
ssrContext.modules.add(entryId)
|
for (const id of await getEntryIds()) {
|
||||||
} else if (ssrContext._registeredComponents) {
|
source.add(id)
|
||||||
ssrContext._registeredComponents.add(entryId)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,10 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
for (const key in manifest) {
|
for (const key in manifest) {
|
||||||
const entry = manifest[key]
|
const entry = manifest[key]
|
||||||
const shouldRemoveCSS = chunksWithInlinedCSS.has(key) && !entry.isEntry
|
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) {
|
if (shouldRemoveCSS && entry.css) {
|
||||||
entry.css = []
|
entry.css = []
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user