File tree Expand file tree Collapse file tree 1 file changed +32
-12
lines changed Expand file tree Collapse file tree 1 file changed +32
-12
lines changed Original file line number Diff line number Diff line change 11import { defineConfig } from './src/config.ts'
22
3+ function timePlugin ( ) {
4+ let startTime : bigint | undefined
5+
6+ const formatDuration = ( ns : bigint ) => {
7+ const ms = Number ( ns ) / 1e6
8+ if ( ms < 1000 ) {
9+ return `${ ms . toFixed ( 2 ) } ms`
10+ }
11+
12+ return `${ ( ms / 1000 ) . toFixed ( 2 ) } s`
13+ }
14+
15+ return {
16+ name : 'robuild-plugin-build' ,
17+ buildStart ( ) {
18+ startTime = process . hrtime . bigint ( )
19+ console . log ( 'buildStart...' )
20+ } ,
21+ async buildEnd ( ) {
22+ const end = process . hrtime . bigint ( )
23+ if ( startTime ) {
24+ const diff = end - startTime
25+ console . log ( `buildEnd... elapsed: ${ formatDuration ( diff ) } ` )
26+ }
27+ else {
28+ console . log ( 'buildEnd...' )
29+ }
30+ } ,
31+ }
32+ }
33+
334export default defineConfig ( {
435 entries : [
536 {
@@ -17,17 +48,6 @@ export default defineConfig({
1748 watchNewFiles : true ,
1849 } ,
1950 plugins : [
20- {
21- name : 'robuild-plugin-build' ,
22- transform ( code , id ) {
23- console . log ( { id } )
24- return {
25- code,
26- }
27- } ,
28- async buildEnd ( ) {
29- console . log ( '✅ buildEnd...' )
30- } ,
31- } ,
51+ timePlugin ( ) ,
3252 ] ,
3353} )
You can’t perform that action at this time.
0 commit comments