Webpack Bundle Analyzer Discussion
Discussion for
Webpack Bundle Analyzer
Thanks Chris. Very timely as I've been trying to optimize my assets.
Two quick suggestions:
- You can skip the duplicate
BundleAnalyzerPlugin
reference by typing this instead:
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
- You probably don't need this plugin in production. So you can add it to your devDependencies instead:
yarn add webpack-bundle-analyzer --dev
Actually, now that I think about it you might run into issues when adding webpack-bundle-analyzer
as just a development dependency. As the webpack config still refers to it.
So if you do want to add it as just a development dependency, make sure to only configure it in config/webpack/development.js
UPDATE:
I was wondering if it still worked with RAILS_ENV=production bin/webpack
. It does. That's unexpected, but what we want in this case. There's probably no harm in loading the dependency in production though, so it might be simplest to stick with Chris' approach.