From 23898bf89bf572d2bef2a99fc927945c92ebb99b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 2 May 2022 22:13:42 +0200 Subject: [PATCH] move dev guard --- packages/nuxt/src/core/nitro.ts | 2 +- packages/vite/src/server.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 7acb8f99865..77bfcbbb0c3 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -139,10 +139,10 @@ export async function initNitro (nuxt: Nuxt) { // nuxt build/dev nuxt.hook('build:done', async () => { + await nuxt.callHook('nitro:build:before', nitro) if (nuxt.options.dev) { await build(nitro) } else { - await nuxt.callHook('nitro:build:before', nitro) await prepare(nitro) await copyPublicAssets(nitro) await prerender(nitro) diff --git a/packages/vite/src/server.ts b/packages/vite/src/server.ts index 09d9ed63b79..cf0204d2cd1 100644 --- a/packages/vite/src/server.ts +++ b/packages/vite/src/server.ts @@ -89,6 +89,9 @@ export async function buildServer (ctx: ViteBuildContext) { await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true }) ctx.nuxt.hook('nitro:build:before', async () => { + if (ctx.nuxt.options.dev) { + return + } const clientDist = resolve(ctx.nuxt.options.buildDir, 'dist/client') // Remove public files that have been duplicated into buildAssetsDir