You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Solution: webpack-bundle-analyzer without ejecting. #3518
Ejecting 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.
changed the title [-]Solution: How to use webpack-bundle-analyzer without ejecting.[/-][+]Solution: webpack-bundle-analyzer without ejecting.[/+]on Nov 29, 2017
@Timer yea the issue doesn't need to be open 👍 In general, source-map-explorer is far less engaging and visually appealing, and I find it more enjoyable to spend time analyzing the bundle with webpack-bundle-analyzer. I know CRA is all about hands-off, but adding a js file with 10 lines of code seemed minimal enough to me.
Reacted by Kevin He, Qwerty (Vítězslav Ackermann Ferko) and Roman D
wanted to do this, but some how i'm getting `Error: Cannot find module 'webpack-bundle-analyzer'
i've installed it and even verified it's in node_modules.
@trevorwhealy
From react-scripts version 2.1.2
there is no more webpack.config.prod so the given answer is breaking.
i have figured out we have to import webpack.config in this way const webpackConfigProd = require("react-scripts/config/webpack.config")('production');
but still report.html is not generated.
Activity
[-]Solution: How to use webpack-bundle-analyzer without ejecting.[/-][+]Solution: webpack-bundle-analyzer without ejecting.[/+]Timer commentedon Dec 8, 2017
We generally recommend source-map-explorer which doesn't require ejecting or a monkey-patch. 😄
https://www.npmjs.com/package/source-map-explorer
I'll close this, people can still find this through search if they're interested.
trevorwhealy commentedon Dec 8, 2017
@Timer yea the issue doesn't need to be open 👍 In general,
source-map-exploreris far less engaging and visually appealing, and I find it more enjoyable to spend time analyzing the bundle withwebpack-bundle-analyzer. I know CRA is all about hands-off, but adding ajsfile with 10 lines of code seemed minimal enough to me.Timer commentedon Dec 8, 2017
I understand! We just try to not flood users with too many options, since you seem like a power user, your solution is fine. 😄
Just be aware it may break in the future, but you should be alright for a while.
murugaratham commentedon Mar 14, 2018
wanted to do this, but some how i'm getting `Error: Cannot find module 'webpack-bundle-analyzer'
i've installed it and even verified it's in node_modules.
murugaratham commentedon Mar 14, 2018
oh, silly me.. i installed webpack-bundle-size-analyzer instead
byzyk commentedon Jun 3, 2018
In case anyone is using
react-app-rewire: I've createdreact-app-rewire-webpack-bundle-analyzerplugin for that.bugzpodder commentedon Jun 3, 2018
I think we are going to add this to CRA2 #3945
cag2050 commentedon Jun 17, 2018
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
marcantoinepelletier commentedon Sep 13, 2018
Worth mentioning if you are using create-react-app with the Typescript settings, you need to change
react-scriptstoreact-scripts-tsin your require.const webpackConfigProd = require('react-scripts-ts/config/webpack.config.prod')and
require('react-scripts-ts/scripts/build')kartikag01 commentedon Jan 9, 2019
@trevorwhealy
From react-scripts version 2.1.2
there is no more
webpack.config.prodso the given answer is breaking.i have figured out we have to import webpack.config in this way
const webpackConfigProd = require("react-scripts/config/webpack.config")('production');but still report.html is not generated.
freund17 commentedon Jan 14, 2019
For everyone coming here from google and using a recent version of react-scripts:
#3945 landed, so now you can use
to include
bundle-stats.jsonandbundle-stats.htmlin yourbuild-directory.(The latter is what you came here for.)