@@ -474,10 +474,11 @@ export async function build(
474
474
'production' ,
475
475
)
476
476
const options = config . build
477
+ const { logger } = config
477
478
const ssr = ! ! options . ssr
478
479
const libOptions = options . lib
479
480
480
- config . logger . info (
481
+ logger . info (
481
482
colors . cyan (
482
483
`vite v${ VERSION } ${ colors . green (
483
484
`building ${ ssr ? `SSR bundle ` : `` } for ${ config . mode } ...` ,
@@ -602,7 +603,7 @@ export async function build(
602
603
const outputBuildError = ( e : RollupError ) => {
603
604
enhanceRollupError ( e )
604
605
clearLine ( )
605
- config . logger . error ( e . message , { error : e } )
606
+ logger . error ( e . message , { error : e } )
606
607
}
607
608
608
609
let bundle : RollupBuild | undefined
@@ -611,7 +612,7 @@ export async function build(
611
612
const buildOutputOptions = ( output : OutputOptions = { } ) : OutputOptions => {
612
613
// @ts -expect-error See https://github.com/vitejs/vite/issues/5812#issuecomment-984345618
613
614
if ( output . output ) {
614
- config . logger . warn (
615
+ logger . warn (
615
616
`You've set "rollupOptions.output.output" in your config. ` +
616
617
`This is deprecated and will override all Vite.js default output options. ` +
617
618
`Please use "rollupOptions.output" instead.` ,
@@ -624,7 +625,7 @@ export async function build(
624
625
)
625
626
}
626
627
if ( output . sourcemap ) {
627
- config . logger . warnOnce (
628
+ logger . warnOnce (
628
629
colors . yellow (
629
630
`Vite does not support "rollupOptions.output.sourcemap". ` +
630
631
`Please use "build.sourcemap" instead.` ,
@@ -688,7 +689,7 @@ export async function build(
688
689
const outputs = resolveBuildOutputs (
689
690
options . rollupOptions ?. output ,
690
691
libOptions ,
691
- config . logger ,
692
+ logger ,
692
693
)
693
694
const normalizedOutputs : OutputOptions [ ] = [ ]
694
695
@@ -709,12 +710,12 @@ export async function build(
709
710
options . emptyOutDir ,
710
711
config . root ,
711
712
resolvedOutDirs ,
712
- config . logger ,
713
+ logger ,
713
714
)
714
715
715
716
// watch file changes with rollup
716
717
if ( config . build . watch ) {
717
- config . logger . info ( colors . cyan ( `\nwatching for file changes...` ) )
718
+ logger . info ( colors . cyan ( `\nwatching for file changes...` ) )
718
719
719
720
const resolvedChokidarOptions = resolveChokidarOptions (
720
721
config ,
@@ -735,13 +736,13 @@ export async function build(
735
736
736
737
watcher . on ( 'event' , ( event ) => {
737
738
if ( event . code === 'BUNDLE_START' ) {
738
- config . logger . info ( colors . cyan ( `\nbuild started...` ) )
739
+ logger . info ( colors . cyan ( `\nbuild started...` ) )
739
740
if ( options . write ) {
740
741
prepareOutDir ( resolvedOutDirs , emptyOutDir , config )
741
742
}
742
743
} else if ( event . code === 'BUNDLE_END' ) {
743
744
event . result . close ( )
744
- config . logger . info ( colors . cyan ( `built in ${ event . duration } ms.` ) )
745
+ logger . info ( colors . cyan ( `built in ${ event . duration } ms.` ) )
745
746
} else if ( event . code === 'ERROR' ) {
746
747
outputBuildError ( event . error )
747
748
}
@@ -763,15 +764,15 @@ export async function build(
763
764
for ( const output of normalizedOutputs ) {
764
765
res . push ( await bundle [ options . write ? 'write' : 'generate' ] ( output ) )
765
766
}
766
- config . logger . info (
767
+ logger . info (
767
768
`${ colors . green ( `✓ built in ${ displayTime ( Date . now ( ) - startTime ) } ` ) } ` ,
768
769
)
769
770
return Array . isArray ( outputs ) ? res : res [ 0 ]
770
771
} catch ( e ) {
771
772
enhanceRollupError ( e )
772
773
clearLine ( )
773
774
if ( startTime ) {
774
- config . logger . error (
775
+ logger . error (
775
776
`${ colors . red ( 'x' ) } Build failed in ${ displayTime ( Date . now ( ) - startTime ) } ` ,
776
777
)
777
778
startTime = undefined
0 commit comments