File tree 1 file changed +35
-0
lines changed
packages/vite/src/node/plugins
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
32
32
let transformedCount = 0
33
33
let chunkCount = 0
34
34
let compressedCount = 0
35
+ let startTime = Date . now ( )
35
36
36
37
async function getCompressedSize (
37
38
code : string | Uint8Array ,
@@ -84,6 +85,10 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
84
85
return null
85
86
} ,
86
87
88
+ options ( ) {
89
+ startTime = Date . now ( )
90
+ } ,
91
+
87
92
buildEnd ( ) {
88
93
if ( shouldLogInfo ) {
89
94
if ( tty ) {
@@ -242,6 +247,16 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
242
247
)
243
248
}
244
249
} ,
250
+
251
+ closeBundle ( ) {
252
+ if ( shouldLogInfo && ! config . build . watch ) {
253
+ config . logger . info (
254
+ `${ colors . green ( `✓` ) } built in ${ displayTime (
255
+ Date . now ( ) - startTime ,
256
+ ) } `,
257
+ )
258
+ }
259
+ } ,
245
260
}
246
261
}
247
262
@@ -276,3 +291,23 @@ function displaySize(bytes: number) {
276
291
minimumFractionDigits : 2 ,
277
292
} ) } kB`
278
293
}
294
+
295
+ function displayTime ( time : number ) {
296
+ // display: {X}ms
297
+ if ( time < 1000 ) {
298
+ return `${ time } ms`
299
+ }
300
+
301
+ time = time / 1000
302
+
303
+ // display: {X}s
304
+ if ( time < 60 ) {
305
+ return `${ time . toFixed ( 2 ) } s`
306
+ }
307
+
308
+ const mins = parseInt ( ( time / 60 ) . toString ( ) )
309
+ const seconds = time % 60
310
+
311
+ // display: {X}m {Y}s
312
+ return `${ mins } m${ seconds < 1 ? '' : ` ${ seconds . toFixed ( 0 ) } s` } `
313
+ }
You can’t perform that action at this time.
0 commit comments