@@ -474,10 +474,11 @@ export async function build(
474474 'production' ,
475475 )
476476 const options = config . build
477+ const { logger } = config
477478 const ssr = ! ! options . ssr
478479 const libOptions = options . lib
479480
480- config . logger . info (
481+ logger . info (
481482 colors . cyan (
482483 `vite v${ VERSION } ${ colors . green (
483484 `building ${ ssr ? `SSR bundle ` : `` } for ${ config . mode } ...` ,
@@ -602,7 +603,7 @@ export async function build(
602603 const outputBuildError = ( e : RollupError ) => {
603604 enhanceRollupError ( e )
604605 clearLine ( )
605- config . logger . error ( e . message , { error : e } )
606+ logger . error ( e . message , { error : e } )
606607 }
607608
608609 let bundle : RollupBuild | undefined
@@ -611,7 +612,7 @@ export async function build(
611612 const buildOutputOptions = ( output : OutputOptions = { } ) : OutputOptions => {
612613 // @ts -expect-error See https://github.com/vitejs/vite/issues/5812#issuecomment-984345618
613614 if ( output . output ) {
614- config . logger . warn (
615+ logger . warn (
615616 `You've set "rollupOptions.output.output" in your config. ` +
616617 `This is deprecated and will override all Vite.js default output options. ` +
617618 `Please use "rollupOptions.output" instead.` ,
@@ -624,7 +625,7 @@ export async function build(
624625 )
625626 }
626627 if ( output . sourcemap ) {
627- config . logger . warnOnce (
628+ logger . warnOnce (
628629 colors . yellow (
629630 `Vite does not support "rollupOptions.output.sourcemap". ` +
630631 `Please use "build.sourcemap" instead.` ,
@@ -688,7 +689,7 @@ export async function build(
688689 const outputs = resolveBuildOutputs (
689690 options . rollupOptions ?. output ,
690691 libOptions ,
691- config . logger ,
692+ logger ,
692693 )
693694 const normalizedOutputs : OutputOptions [ ] = [ ]
694695
@@ -709,12 +710,12 @@ export async function build(
709710 options . emptyOutDir ,
710711 config . root ,
711712 resolvedOutDirs ,
712- config . logger ,
713+ logger ,
713714 )
714715
715716 // watch file changes with rollup
716717 if ( config . build . watch ) {
717- config . logger . info ( colors . cyan ( `\nwatching for file changes...` ) )
718+ logger . info ( colors . cyan ( `\nwatching for file changes...` ) )
718719
719720 const resolvedChokidarOptions = resolveChokidarOptions (
720721 config ,
@@ -735,13 +736,13 @@ export async function build(
735736
736737 watcher . on ( 'event' , ( event ) => {
737738 if ( event . code === 'BUNDLE_START' ) {
738- config . logger . info ( colors . cyan ( `\nbuild started...` ) )
739+ logger . info ( colors . cyan ( `\nbuild started...` ) )
739740 if ( options . write ) {
740741 prepareOutDir ( resolvedOutDirs , emptyOutDir , config )
741742 }
742743 } else if ( event . code === 'BUNDLE_END' ) {
743744 event . result . close ( )
744- config . logger . info ( colors . cyan ( `built in ${ event . duration } ms.` ) )
745+ logger . info ( colors . cyan ( `built in ${ event . duration } ms.` ) )
745746 } else if ( event . code === 'ERROR' ) {
746747 outputBuildError ( event . error )
747748 }
@@ -763,15 +764,15 @@ export async function build(
763764 for ( const output of normalizedOutputs ) {
764765 res . push ( await bundle [ options . write ? 'write' : 'generate' ] ( output ) )
765766 }
766- config . logger . info (
767+ logger . info (
767768 `${ colors . green ( `✓ built in ${ displayTime ( Date . now ( ) - startTime ) } ` ) } ` ,
768769 )
769770 return Array . isArray ( outputs ) ? res : res [ 0 ]
770771 } catch ( e ) {
771772 enhanceRollupError ( e )
772773 clearLine ( )
773774 if ( startTime ) {
774- config . logger . error (
775+ logger . error (
775776 `${ colors . red ( 'x' ) } Build failed in ${ displayTime ( Date . now ( ) - startTime ) } ` ,
776777 )
777778 startTime = undefined
0 commit comments