Skip to content

Commit

Permalink
fix: analyze script doesn't persist stats.json (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki authored Nov 7, 2024
1 parent de171e3 commit dbbdd70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,22 @@ function webpackOverride (config) {
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
}),
new BundleAnalyzerPlugin({
generateStatsFile: true,
analyzerMode: 'disabled',
openAnalyzer: false
})
])

/**
* NODE_ENV is overridden by react-scripts/react-app-rewired-esm,
* so we set BUILD_ENV in the analyze script
*/
if (process.env.BUILD_ENV === 'analyze') {
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
openAnalyzer: true
})
)
}

config.module.rules = modifyBabelLoaderRuleForBuild(config.module.rules)
config.module.rules.push({
test: /\.jsx?$/,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test:e2e": "cross-env REACT_APP_ENV=test npx playwright test -c ./test/e2e",
"test:build": "cross-env REACT_APP_ENV=test run-s build",
"test:coverage": "jest --coverage",
"analyze": "webpack-bundle-analyzer build/stats.json",
"analyze": "cross-env BUILD_ENV=analyze npm run build",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009",
"build-storybook": "build-storybook --modern",
Expand Down

0 comments on commit dbbdd70

Please sign in to comment.