feat(vite): display production build stats (#9761)

This commit is contained in:
Anthony Fu 2022-12-19 12:57:08 +01:00 committed by GitHub
parent 04c8625843
commit faf260757c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -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)) {

View File

@ -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'),

View File

@ -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`)
}

View File

@ -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()