mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat(vite): display production build stats (#9761)
This commit is contained in:
parent
04c8625843
commit
faf260757c
@ -3,7 +3,7 @@ import { resolve, join } from 'pathe'
|
|||||||
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
|
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
|
||||||
import type { NitroConfig, Nitro } from 'nitropack'
|
import type { NitroConfig, Nitro } from 'nitropack'
|
||||||
import type { Nuxt } from '@nuxt/schema'
|
import type { Nuxt } from '@nuxt/schema'
|
||||||
import { resolvePath } from '@nuxt/kit'
|
import { logger, resolvePath } from '@nuxt/kit'
|
||||||
import escapeRE from 'escape-string-regexp'
|
import escapeRE from 'escape-string-regexp'
|
||||||
import defu from 'defu'
|
import defu from 'defu'
|
||||||
import fsExtra from 'fs-extra'
|
import fsExtra from 'fs-extra'
|
||||||
@ -202,7 +202,9 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
|
|||||||
await copyPublicAssets(nitro)
|
await copyPublicAssets(nitro)
|
||||||
await prerender(nitro)
|
await prerender(nitro)
|
||||||
if (!nuxt.options._generate) {
|
if (!nuxt.options._generate) {
|
||||||
|
logger.restoreAll()
|
||||||
await build(nitro)
|
await build(nitro)
|
||||||
|
logger.wrapAll()
|
||||||
} else {
|
} else {
|
||||||
const distDir = resolve(nuxt.options.rootDir, 'dist')
|
const distDir = resolve(nuxt.options.rootDir, 'dist')
|
||||||
if (!existsSync(distDir)) {
|
if (!existsSync(distDir)) {
|
||||||
|
@ -18,7 +18,9 @@ export default defineUntypedSchema({
|
|||||||
mode: {
|
mode: {
|
||||||
$resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production')
|
$resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production')
|
||||||
},
|
},
|
||||||
logLevel: 'warn',
|
logLevel:{
|
||||||
|
$resolve: async (val, get) => val ?? (await get('dev') ? 'warn' : 'info')
|
||||||
|
},
|
||||||
define: {
|
define: {
|
||||||
$resolve: async (val, get) => ({
|
$resolve: async (val, get) => ({
|
||||||
'process.dev': await get('dev'),
|
'process.dev': await get('dev'),
|
||||||
|
@ -151,7 +151,9 @@ export async function buildClient (ctx: ViteBuildContext) {
|
|||||||
// Build
|
// Build
|
||||||
logger.info('Building client...')
|
logger.info('Building client...')
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
|
logger.restoreAll()
|
||||||
await vite.build(clientConfig)
|
await vite.build(clientConfig)
|
||||||
|
logger.wrapAll()
|
||||||
await ctx.nuxt.callHook('vite:compiled')
|
await ctx.nuxt.callHook('vite:compiled')
|
||||||
logger.success(`Client built in ${Date.now() - start}ms`)
|
logger.success(`Client built in ${Date.now() - start}ms`)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,9 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
if (!ctx.nuxt.options.dev) {
|
if (!ctx.nuxt.options.dev) {
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
logger.info('Building server...')
|
logger.info('Building server...')
|
||||||
|
logger.restoreAll()
|
||||||
await vite.build(serverConfig)
|
await vite.build(serverConfig)
|
||||||
|
logger.wrapAll()
|
||||||
// Write production client manifest
|
// Write production client manifest
|
||||||
await writeManifest(ctx)
|
await writeManifest(ctx)
|
||||||
await onBuild()
|
await onBuild()
|
||||||
|
Loading…
Reference in New Issue
Block a user