File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ export const measureRspressBuildPlugin = () => ({
25
25
api . onAfterBuild ( async ( ) => {
26
26
const buildTime = performance . now ( ) - beforeBuildTime ;
27
27
metrics . buildColdBootTime = buildTime ;
28
- await saveMetrics ( metrics ) ;
28
+ if ( api . context . target === 'web' ) {
29
+ await saveMetrics ( metrics ) ;
30
+ }
29
31
} ) ;
30
32
31
33
api . onBeforeStartDevServer ( ( ) => {
Original file line number Diff line number Diff line change 7
7
outputJson ,
8
8
outputFile ,
9
9
pathExists ,
10
+ readJsonSync ,
11
+ outputJsonSync ,
10
12
} from 'fs-extra' ;
11
13
import logger from 'consola' ;
12
14
import type { Metrics } from './types' ;
@@ -65,17 +67,17 @@ export async function saveMetrics(metrics: Metrics) {
65
67
const { jsonPath, jsonName } = await getMetricsPath ( PRODUCT_NAME , CASE_NAME ) ;
66
68
67
69
if ( await pathExists ( jsonPath ) ) {
68
- const content : Metrics [ ] = await readJson ( jsonPath ) ;
70
+ const content : Metrics [ ] = readJsonSync ( jsonPath ) ;
69
71
70
72
if ( content [ index ] ) {
71
73
Object . assign ( content [ index ] , metrics ) ;
72
74
} else {
73
75
content . push ( metrics ) ;
74
76
}
75
77
76
- await outputJson ( jsonPath , content , { spaces : 2 } ) ;
78
+ outputJsonSync ( jsonPath , content , { spaces : 2 } ) ;
77
79
} else {
78
- await outputJson ( jsonPath , [ metrics ] , { spaces : 2 } ) ;
80
+ outputJsonSync ( jsonPath , [ metrics ] , { spaces : 2 } ) ;
79
81
}
80
82
81
83
logger . success ( `Successfully write metrics to ${ jsonName } .` ) ;
You can’t perform that action at this time.
0 commit comments