diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 88e86517dd..51f1b527ca 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -232,6 +232,19 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { handler: resolve(distDir, 'core/runtime/nitro/renderer') }) + if (nuxt.options.experimental.noVueServer) { + nitro.hooks.hook('rollup:before', (nitro) => { + if (nitro.options.preset === 'nitro-prerender') { return } + const nuxtErrorHandler = nitro.options.handlers.findIndex(h => h.route === '/__nuxt_error') + if (nuxtErrorHandler >= 0) { + nitro.options.handlers.splice(nuxtErrorHandler, 1) + } + // @ts-expect-error TODO: https://github.com/unjs/nitro/pull/1069 + nitro.options.renderer = undefined + nitro.options.errorHandler = '#internal/nitro/error' + }) + } + // Add typed route responses nuxt.hook('prepare:types', async (opts) => { if (!nuxt.options.dev) { @@ -261,7 +274,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { } else { const distDir = resolve(nuxt.options.rootDir, 'dist') if (!existsSync(distDir)) { - await fsp.symlink(nitro.options.output.publicDir, distDir, 'junction').catch(() => { }) + await fsp.symlink(nitro.options.output.publicDir, distDir, 'junction').catch(() => {}) } } } diff --git a/packages/schema/src/config/experimental.ts b/packages/schema/src/config/experimental.ts index a92cf33b37..1d696fbcb5 100644 --- a/packages/schema/src/config/experimental.ts +++ b/packages/schema/src/config/experimental.ts @@ -100,7 +100,7 @@ export default defineUntypedSchema({ * @type {boolean | ((id?: string) => boolean)} */ inlineSSRStyles: { - async $resolve(val, get) { + async $resolve (val, get) { if (val === false || (await get('dev')) || (await get('ssr')) === false || (await get('builder')) === '@nuxt/webpack-builder') { return false } @@ -114,6 +114,11 @@ export default defineUntypedSchema({ */ noScripts: false, + /** + * Disable vue server renderer endpoint within nitro. + */ + noVueServer: false, + /** * When this option is enabled (by default) payload of pages generated with `nuxt generate` are extracted */