diff --git a/packages/nitro/src/runtime/app/render.ts b/packages/nitro/src/runtime/app/render.ts index cbc23e5c1a..70fdd3924e 100644 --- a/packages/nitro/src/runtime/app/render.ts +++ b/packages/nitro/src/runtime/app/render.ts @@ -10,7 +10,7 @@ const NUXT_NO_SSR = process.env.NUXT_NO_SSR const PAYLOAD_JS = '/payload.js' const getClientManifest = cachedImport(() => import('#build/dist/server/client.manifest.mjs')) -const getSSRApp = cachedImport(() => import('#build/dist/server/server.mjs')) +const getSSRApp = !process.env.NUXT_NO_SSR && cachedImport(() => import('#build/dist/server/server.mjs')) const publicPath = (publicConfig.app && publicConfig.app.assetsPath) || process.env.PUBLIC_PATH || '/_nuxt' @@ -33,14 +33,32 @@ const getSPARenderer = cachedResult(async () => { serverRendered: false, config: publicConfig } + + let entryFiles = Object.values(clientManifest).filter( + (fileValue: any) => fileValue.isEntry + ) + if ('all' in clientManifest && 'initial' in clientManifest) { + // Upgrade legacy manifest (also see normalizeClientManifest in vue-bundle-renderer) + // https://github.com/nuxt-contrib/vue-bundle-renderer/issues/12 + entryFiles = clientManifest.initial.map(file => ({ file })) + } + return { html: '
', renderResourceHints: () => '', - renderStyles: () => '', - renderScripts: () => clientManifest.initial.map((s) => { - const isMJS = !s.endsWith('.js') - return `` - }).join('') + renderStyles: () => + entryFiles + .flatMap(({ css }) => css) + .filter(css => css != null) + .map(file => ``) + .join(''), + renderScripts: () => + entryFiles + .map(({ file }) => { + const isMJS = !file.endsWith('.js') + return `` + }) + .join('') } } })