Solution: webpack-bundle-analyzer without ejecting.
See original GitHub issueEjecting is a real shame for any instance of create-react-app, so I found a way to use webpack-bundle-analyzer without ejecting. Hopefully this will save someone out there from having to eject to make this addition.
- Create a file in root, I call mine “build.js”
- Add this javascript.
process.env.NODE_ENV = "production"
var BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin
const webpackConfigProd = require("react-scripts/config/webpack.config.prod")
webpackConfigProd.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFilename: "report.html",
})
)
require("react-scripts/scripts/build")
node build.js
Issue Analytics
- State:
- Created 6 years ago
- Reactions:96
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Webpack Bundle Analyzer with Create React App ... - YouTube
Webpack Bundle Analyzer with Create React App without ejecting. ; https://www.udemy.com/user/maksym-rud... Support this channel: Patreon - ; https ...
Read more >You can use create-react-app with webpack-bundle ...
You can use create-react-app with webpack-bundle-analyzer without ejecting: npm run build -- --stats.
Read more >[Without Ejecting] Analyze Create React App Bundle Size
[Without Ejecting] Analyze Create React App Bundle Size ... The webpack-bundle-analyzer is a great package to analyze the bundle size of ReactJS app....
Read more >Analyze your Create React App bundle size - without ejecting
Step 1 - Dependencies The plugin we'll use to analyze bundle size is webpack-bundle-analyzer. To avoid ejecting we'll be using CRACO (Create ...
Read more >How to configure webpack-bundle-analyzer for react?
4 Answers 4 · Add some dependencies by executing npm install --save-dev progress-bar-webpack-plugin webpack-bundle-analyzer · Create a new folder ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Add webpack-bundle-analyzer with ejecting, modify code in file: config/webpack.config.prod.js.
demo: https://github.com/cag2050/antd_mobx_demo/blob/master/config/webpack.config.prod.js
For everyone coming here from google and using a recent version of react-scripts: https://github.com/facebook/create-react-app/pull/3945 landed, so now you can use
to include
bundle-stats.json
andbundle-stats.html
in yourbuild
-directory. (The latter is what you came here for.)