Closed
Description
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.
- 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
Metadata
Metadata
Assignees
Labels
No labels