Ask A Question

Notifications

You’re not receiving notifications from this thread.

Webpack Bundle Analyzer Discussion

Discussion for Webpack Bundle Analyzer

Cant wait for the split chunks episode!

Reply

Thanks Chris. Very timely as I've been trying to optimize my assets.

Two quick suggestions:

  1. You can skip the duplicate BundleAnalyzerPlugin reference by typing this instead:
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
  1. You probably don't need this plugin in production. So you can add it to your devDependencies instead:
yarn add webpack-bundle-analyzer --dev
Reply

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.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.