Skip to content

Commit dbbdd70

Browse files
authored
fix: analyze script doesn't persist stats.json (ipfs#2290)
1 parent de171e3 commit dbbdd70

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

config-overrides.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,22 @@ function webpackOverride (config) {
9090
new webpack.ProvidePlugin({
9191
process: 'process/browser',
9292
Buffer: ['buffer', 'Buffer']
93-
}),
94-
new BundleAnalyzerPlugin({
95-
generateStatsFile: true,
96-
analyzerMode: 'disabled',
97-
openAnalyzer: false
9893
})
9994
])
10095

96+
/**
97+
* NODE_ENV is overridden by react-scripts/react-app-rewired-esm,
98+
* so we set BUILD_ENV in the analyze script
99+
*/
100+
if (process.env.BUILD_ENV === 'analyze') {
101+
config.plugins.push(
102+
new BundleAnalyzerPlugin({
103+
analyzerMode: 'server',
104+
openAnalyzer: true
105+
})
106+
)
107+
}
108+
101109
config.module.rules = modifyBabelLoaderRuleForBuild(config.module.rules)
102110
config.module.rules.push({
103111
test: /\.jsx?$/,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"test:e2e": "cross-env REACT_APP_ENV=test npx playwright test -c ./test/e2e",
3030
"test:build": "cross-env REACT_APP_ENV=test run-s build",
3131
"test:coverage": "jest --coverage",
32-
"analyze": "webpack-bundle-analyzer build/stats.json",
32+
"analyze": "cross-env BUILD_ENV=analyze npm run build",
3333
"eject": "react-scripts eject",
3434
"storybook": "start-storybook -p 9009",
3535
"build-storybook": "build-storybook --modern",

0 commit comments

Comments
 (0)