background
Create-react-app builds the webpack-bundle-Analyzer to analyze file sizes.
steps
1. Run NPM run eject to save the configuration file locally.
Install NPM install webpack-bundle-Analyzer –save-dev
3. In config/webpack.config.js,
add
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
Copy the code
New Webpack.ignoReplugIn add new BundleAnalyzerPlugin()
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new BundleAnalyzerPlugin(),
Copy the code
4. Run NPM run build to check the js file size
tips:
NPM run eject is used with caution in formal code