mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 16:25:55 +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 })
|
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 { colorize } from 'consola/utils'
|
||||||
import { hasTTY, isCI } from 'std-env'
|
import { hasTTY, isCI } from 'std-env'
|
||||||
import type { NuxtOptions } from '@nuxt/schema'
|
import type { NuxtOptions } from '@nuxt/schema'
|
||||||
|
import { relative } from 'pathe'
|
||||||
import { useResolveFromPublicAssets } from '../plugins/public-dirs'
|
import { useResolveFromPublicAssets } from '../plugins/public-dirs'
|
||||||
|
|
||||||
let duplicateCount = 0
|
let duplicateCount = 0
|
||||||
@ -24,10 +25,11 @@ const logLevelMapReverse: Record<NonNullable<vite.UserConfig['logLevel']>, numbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
const RUNTIME_RESOLVE_REF_RE = /^([^ ]+) referenced in/m
|
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 loggedErrors = new WeakSet<any>()
|
||||||
const canClearScreen = hasTTY && !isCI && config.clearScreen
|
const canClearScreen = hasTTY && !isCI && config.clearScreen
|
||||||
const _logger = createLogger()
|
const _logger = createLogger()
|
||||||
|
const relativeOutDir = relative(config.root!, config.build!.outDir || '')
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
_logger.clearScreen(
|
_logger.clearScreen(
|
||||||
// @ts-expect-error silent is a log level but not a valid option for clearScreens
|
// @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]
|
const id = msg.trim().match(RUNTIME_RESOLVE_REF_RE)?.[1]
|
||||||
if (id && resolveFromPublicAssets(id)) { return }
|
if (id && resolveFromPublicAssets(id)) { return }
|
||||||
}
|
}
|
||||||
|
if (type === 'info' && ctx.hideOutput && msg.includes(relativeOutDir)) { return }
|
||||||
}
|
}
|
||||||
|
|
||||||
const sameAsLast = lastType === type && lastMsg === msg
|
const sameAsLast = lastType === type && lastMsg === msg
|
||||||
|
Loading…
Reference in New Issue
Block a user