From 20e88bb171b34a749f5468238815b022163e262e Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 16 Jan 2024 12:36:26 +0000 Subject: [PATCH] fix(nuxt): render user-inserted links in island responses (#25219) --- .../nuxt/src/core/runtime/nitro/renderer.ts | 52 ++++++++++--------- test/bundle.test.ts | 2 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index 69813f39b5..3f412545cf 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -229,9 +229,8 @@ export default defineRenderHandler(async (event): Promise> @@ -241,7 +240,7 @@ export default defineRenderHandler(async (event): Promise - ({ rel: 'stylesheet', href: renderer.rendererContext.buildAssetsURL(resource.file) }) - ) - }, headEntryOptions) + if (!isRenderingIsland || import.meta.dev) { + const link = [] + for (const style in styles) { + const resource = styles[style] + if (!import.meta.dev || (resource.file.includes('scoped') && !resource.file.includes('pages/'))) { + link.push({ rel: 'stylesheet', href: renderer.rendererContext.buildAssetsURL(resource.file) }) + } + } + head.push({ link }, headEntryOptions) + } - if (!NO_SCRIPTS) { + if (!NO_SCRIPTS && !isRenderingIsland) { // 3. Resource Hints // TODO: add priorities based on Capo head.push({ @@ -395,7 +400,7 @@ export default defineRenderHandler(async (event): Promise (