fix(nuxt): use virtual server stub with `ssr: false` (#5773)

This commit is contained in:
pooya parsa 2022-07-07 18:51:42 +02:00 committed by GitHub
parent 079ff4439c
commit f321a56e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -29,6 +29,7 @@ export async function initNitro (nuxt: Nuxt) {
handlers,
devHandlers: [],
baseURL: nuxt.options.app.baseURL,
virtual: {},
runtimeConfig: {
...nuxt.options.runtimeConfig,
nitro: {
@ -100,6 +101,11 @@ export async function initNitro (nuxt: Nuxt) {
}
})
// Add fallback server for `ssr: false`
if (!nuxt.options.ssr) {
nitroConfig.virtual['#build/dist/server/server.mjs'] = 'export default () => {}'
}
// Extend nitro config with hook
await nuxt.callHook('nitro:config', nitroConfig)

View File

@ -35,7 +35,7 @@ const getClientManifest = () => import('#build/dist/server/client.manifest.mjs')
.then(r => typeof r === 'function' ? r() : r)
// @ts-ignore
const getServerEntry = () => process.env.NUXT_NO_SSR ? Promise.resolve(null) : import('#build/dist/server/server.mjs').then(r => r.default || r)
const getServerEntry = () => import('#build/dist/server/server.mjs').then(r => r.default || r)
// -- SSR Renderer --
const getSSRRenderer = lazyCachedFunction(async () => {