mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 08:15:59 +00:00
fix(vite): don't show interim vite build output files (#31439)
This commit is contained in:
parent
26d0e18061
commit
8b21c54980
@ -131,7 +131,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
})
|
||||
}
|
||||
|
||||
serverConfig.customLogger = createViteLogger(serverConfig)
|
||||
serverConfig.customLogger = createViteLogger(serverConfig, { hideOutput: !ctx.nuxt.options.dev })
|
||||
|
||||
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { logger } from '@nuxt/kit'
|
||||
import { colorize } from 'consola/utils'
|
||||
import { hasTTY, isCI } from 'std-env'
|
||||
import type { NuxtOptions } from '@nuxt/schema'
|
||||
import { relative } from 'pathe'
|
||||
import { useResolveFromPublicAssets } from '../plugins/public-dirs'
|
||||
|
||||
let duplicateCount = 0
|
||||
@ -24,10 +25,11 @@ const logLevelMapReverse: Record<NonNullable<vite.UserConfig['logLevel']>, numbe
|
||||
}
|
||||
|
||||
const RUNTIME_RESOLVE_REF_RE = /^([^ ]+) referenced in/m
|
||||
export function createViteLogger (config: vite.InlineConfig): vite.Logger {
|
||||
export function createViteLogger (config: vite.InlineConfig, ctx: { hideOutput?: boolean } = {}): vite.Logger {
|
||||
const loggedErrors = new WeakSet<any>()
|
||||
const canClearScreen = hasTTY && !isCI && config.clearScreen
|
||||
const _logger = createLogger()
|
||||
const relativeOutDir = relative(config.root!, config.build!.outDir || '')
|
||||
const clear = () => {
|
||||
_logger.clearScreen(
|
||||
// @ts-expect-error silent is a log level but not a valid option for clearScreens
|
||||
@ -48,6 +50,7 @@ export function createViteLogger (config: vite.InlineConfig): vite.Logger {
|
||||
const id = msg.trim().match(RUNTIME_RESOLVE_REF_RE)?.[1]
|
||||
if (id && resolveFromPublicAssets(id)) { return }
|
||||
}
|
||||
if (type === 'info' && ctx.hideOutput && msg.includes(relativeOutDir)) { return }
|
||||
}
|
||||
|
||||
const sameAsLast = lastType === type && lastMsg === msg
|
||||
|
Loading…
Reference in New Issue
Block a user