fix(nuxt): skip server build with generate (#4472)

This commit is contained in:
pooya parsa 2022-04-20 21:12:04 +02:00 committed by GitHub
parent be804742f5
commit 3c3291226d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { existsSync } from 'node:fs'
import { existsSync, promises as fsp } from 'node:fs'
import { resolve, join } from 'pathe'
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
import type { NitroEventHandler, NitroDevEventHandler, NitroConfig } from 'nitropack'
@ -144,7 +144,14 @@ export async function initNitro (nuxt: Nuxt) {
await prepare(nitro)
await copyPublicAssets(nitro)
await prerender(nitro)
await build(nitro)
if (!nuxt.options._generate) {
await build(nitro)
} else {
const distDir = resolve(nuxt.options.rootDir, 'dist')
if (!existsSync(distDir)) {
await fsp.symlink(nitro.options.output.publicDir, distDir, 'junction').catch(() => {})
}
}
}
})