question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Analyze gzipped bundles

See original GitHub issue

Issue description

webpack-bundle-analyzer currently displays a blank page when a webpack build uses compression-webpack-plugin to compress bundles.

Technical info

Using the following workaround. This skips compression when webpack build command is used with ‘analyze’ environment variable.

module.exports = ({ env, analyze }) => {
  switch (env) {
    case 'development':
      return merge(commonConfig, developmentConfig);
    case 'production':
      if (analyze) commonConfig.plugins.push(new BundleAnalyzerPlugin());
      else
        productionConfig.plugins.push(
          new CompressionPlugin({
            filename: '[path].gz',
            algorithm: 'gzip',
            test: /\.(js|jsx|css|html|png|svg|jpg|gif)$/,
            threshold: 10240,
            minRatio: 0.8,
            deleteOriginalAssets: true,
          })
        );
      return merge(commonConfig, productionConfig);
    default:
      throw new Error('No matching configuration was found!');
  }
};
  System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 8.06 GB / 15.81 GB
  Binaries:
    Node: 12.18.1 - ~\Apps\Node\node.EXE
    npm: 6.14.5 - ~\Apps\Node\npm.CMD
  npmPackages:
    clean-webpack-plugin: ^3.0.0 => 3.0.0 
    compression-webpack-plugin: ^4.0.1 => 4.0.1 
    html-webpack-plugin: ^4.3.0 => 4.3.0 
    optimize-css-assets-webpack-plugin: ^5.0.3 => 5.0.3 
    webpack: ^4.44.1 => 4.44.1 
    webpack-bundle-analyzer: ^3.8.0 => 3.8.0 
    webpack-cli: ^3.3.12 => 3.3.12 
    webpack-dev-server: ^3.11.0 => 3.11.0 
    webpack-merge: ^5.1.1 => 5.1.1 

Debug info

How do you use this module? As CLI utility or as plugin? -Both

If CLI, what command was used? (e.g. webpack-bundle-analyzer -O path/to/stats.json)

If plugin, what options were provided? (e.g. new BundleAnalyzerPlugin({ analyzerMode: 'disabled', generateStatsFile: true })) new BundleAnalyzerPlugin()

What other Webpack plugins were used? clean-webpack-plugin: ^3.0.0 => 3.0.0 compression-webpack-plugin: ^4.0.1 => 4.0.1 html-webpack-plugin: ^4.3.0 => 4.3.0 optimize-css-assets-webpack-plugin: ^5.0.3 => 5.0.3 webpack: ^4.44.1 => 4.44.1 webpack-bundle-analyzer: ^3.8.0 => 3.8.0 webpack-cli: ^3.3.12 => 3.3.12 webpack-dev-server: ^3.11.0 => 3.11.0 webpack-merge: ^5.1.1 => 5.1.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
grugcommented, Sep 15, 2022

For the time being I’ve just had to run a separate build and pass in a “isStatsBuild” parameter to webpack to omit the compression. It works - not ideal, though.

1reaction
xittercommented, Aug 28, 2020

@RedVelocity @valscion Brotli also worked well as zlib supports it, PR on the way.

Config for brotli:

new CompressionPlugin({
  filename: '[path].br',
  algorithm: 'brotliCompress',
  test: /\.(js|jsx|css|html|png|svg|jpg|gif)$/,
  compressionOptions: {
     // zlib’s `level` option matches Brotli’s `BROTLI_PARAM_QUALITY` option.
     level: 11,
  },
  threshold: 10240,
  minRatio: 0.8,
  deleteOriginalAssets: true,
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Tools and Techniques to Analyze Webpack Bundle Size
There are 2 approaches to analyze bundle size using Webpack Visualizer. ... Get an idea about parse and gzipped sizes of modules.
Read more >
webpack-bundle-analyzer - npm
And the best thing is it supports minified bundles! It parses them to get real size of bundled modules. And it also shows...
Read more >
How to use Webpack Analyzer Bundle - Digital Fortress
When you hover over any of the bundles, you will see the stat size, the parsed size as well as the gzipped size...
Read more >
How to investigate your build size in Webpack - Saeloun Blog
Inspecting a bundle · This is a beta functionality where we can scan a package. · The web-app then scans the file and...
Read more >
How to use the webpack bundle analyzer - Jakob Lind
Should you analyze the production or dev bundle? Webpack bundle analyzer react ... const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found