mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
fix(nitro): fix rendering with ssr
disabled (#2191)
This commit is contained in:
parent
87db67181f
commit
1c88580c8c
@ -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: '<div id="__nuxt"></div>',
|
||||
renderResourceHints: () => '',
|
||||
renderStyles: () => '',
|
||||
renderScripts: () => clientManifest.initial.map((s) => {
|
||||
const isMJS = !s.endsWith('.js')
|
||||
return `<script ${isMJS ? 'type="module"' : ''} src="${publicPath}${s}"></script>`
|
||||
}).join('')
|
||||
renderStyles: () =>
|
||||
entryFiles
|
||||
.flatMap(({ css }) => css)
|
||||
.filter(css => css != null)
|
||||
.map(file => `<link rel="stylesheet" href="${publicPath}${file}">`)
|
||||
.join(''),
|
||||
renderScripts: () =>
|
||||
entryFiles
|
||||
.map(({ file }) => {
|
||||
const isMJS = !file.endsWith('.js')
|
||||
return `<script ${isMJS ? 'type="module"' : ''} src="${publicPath}${file}"></script>`
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user