From faf260757cb9636dd78d79e45813fde5a4a36359 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 19 Dec 2022 12:57:08 +0100 Subject: [PATCH] feat(vite): display production build stats (#9761) --- packages/nuxt/src/core/nitro.ts | 4 +++- packages/schema/src/config/vite.ts | 4 +++- packages/vite/src/client.ts | 2 ++ packages/vite/src/server.ts | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 038a135d2f..2c47536646 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -3,7 +3,7 @@ import { resolve, join } from 'pathe' import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack' import type { NitroConfig, Nitro } from 'nitropack' import type { Nuxt } from '@nuxt/schema' -import { resolvePath } from '@nuxt/kit' +import { logger, resolvePath } from '@nuxt/kit' import escapeRE from 'escape-string-regexp' import defu from 'defu' import fsExtra from 'fs-extra' @@ -202,7 +202,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) { await copyPublicAssets(nitro) await prerender(nitro) if (!nuxt.options._generate) { + logger.restoreAll() await build(nitro) + logger.wrapAll() } else { const distDir = resolve(nuxt.options.rootDir, 'dist') if (!existsSync(distDir)) { diff --git a/packages/schema/src/config/vite.ts b/packages/schema/src/config/vite.ts index 19ab38c82f..2add95dc35 100644 --- a/packages/schema/src/config/vite.ts +++ b/packages/schema/src/config/vite.ts @@ -18,7 +18,9 @@ export default defineUntypedSchema({ mode: { $resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production') }, - logLevel: 'warn', + logLevel:{ + $resolve: async (val, get) => val ?? (await get('dev') ? 'warn' : 'info') + }, define: { $resolve: async (val, get) => ({ 'process.dev': await get('dev'), diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index 7287e0e048..f2d134ec84 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -151,7 +151,9 @@ export async function buildClient (ctx: ViteBuildContext) { // Build logger.info('Building client...') const start = Date.now() + logger.restoreAll() await vite.build(clientConfig) + logger.wrapAll() await ctx.nuxt.callHook('vite:compiled') logger.success(`Client built in ${Date.now() - start}ms`) } diff --git a/packages/vite/src/server.ts b/packages/vite/src/server.ts index 018e6ad4db..ce406d4fca 100644 --- a/packages/vite/src/server.ts +++ b/packages/vite/src/server.ts @@ -138,7 +138,9 @@ export async function buildServer (ctx: ViteBuildContext) { if (!ctx.nuxt.options.dev) { const start = Date.now() logger.info('Building server...') + logger.restoreAll() await vite.build(serverConfig) + logger.wrapAll() // Write production client manifest await writeManifest(ctx) await onBuild()