diff --git a/packages/nuxt/src/core/runtime/nitro/renderer.ts b/packages/nuxt/src/core/runtime/nitro/renderer.ts index ce6c682ff1..65e40cc6a6 100644 --- a/packages/nuxt/src/core/runtime/nitro/renderer.ts +++ b/packages/nuxt/src/core/runtime/nitro/renderer.ts @@ -224,7 +224,7 @@ function renderHTMLDocument (html: NuxtRenderHTMLContext) { async function renderInlineStyles (usedModules: Set | string[]) { const styleMap = await getSSRStyles() const inlinedStyles = new Set() - for (const mod of usedModules) { + for (const mod of ['entry', ...usedModules]) { if (mod in styleMap) { for (const style of await styleMap[mod]()) { inlinedStyles.add(``) diff --git a/packages/vite/src/plugins/ssr-styles.ts b/packages/vite/src/plugins/ssr-styles.ts index 84232ed721..7015728534 100644 --- a/packages/vite/src/plugins/ssr-styles.ts +++ b/packages/vite/src/plugins/ssr-styles.ts @@ -60,11 +60,11 @@ export function ssrStylesPlugin (options: SSRStylePluginOptions): Plugin { source: [ ...globalStylesArray.map((css, i) => `import style_${i} from './${css}';`), - `const globalStyles = [${globalStylesArray.map((_, i) => `style_${i}`).join(', ')}]`, - 'const resolveStyles = r => globalStyles.concat(r.default || r || [])', - `export default ${genObjectFromRawEntries( - Object.entries(emitted).map(([key, value]) => [key, `() => import('./${this.getFileName(value)}').then(resolveStyles)`]) - )}` + 'const interopDefault = r => r.default || r || []', + `export default ${genObjectFromRawEntries([ + ['entry', `() => [${globalStylesArray.map((_, i) => `style_${i}`).join(', ')}]`], + ...Object.entries(emitted).map(([key, value]) => [key, `() => import('./${this.getFileName(value)}').then(interopDefault)`]) as [string, string][] + ])}` ].join('\n') }) },