Skip to content

nimacsoft/razzle-plugin-bundle-analyzer

Repository files navigation

npm version

All Contributors

razzle-plugin-bundle-analyzer

This package contains a plugin for using webpack-bundle-analyzer with Razzle

Usage in Razzle Projects

yarn add razzle-plugin-bundle-analyzer --dev

create a razzle.config.js file in root directory of project (next to the package.json) and put this content inside it

Using the plugin with the default options

// razzle.config.js

module.exports = {
  plugins: ['bundle-analyzer'],
};

With custom options:

// razzle.config.js

module.exports = {
  plugins: [
    {
      name: 'bundle-analyzer',
      options: {
        concatenateModules: false
      }
    }
  ]
};

Options

concatenateModules: boolean (defaults: false)

Set concatenateModules to true if you want to webpack to find segments of the module graph which can be safely concatenated into a single module

Customizing

You can also pass other webpack-bundle-analyzer options in the options array. For example, to use this in Docker environments, you can set the analyzerHost to 0.0.0.0.

// razzle.config.js

module.exports = {
  plugins: [
    {
      name: 'bundle-analyzer',
      options: {
        analyzerHost: '0.0.0.0'
      }
    }
  ]
};

See the full list of possible options here

Run Bundle Analyzer

Craete a new script in package.json

"analyze": "BUNDLE_ANALYZE=true razzle build",

and start by run this command in terminal

yarn analyze

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Nima Arefi

🚇 ⚠️ 💻

This project follows the all-contributors specification. Contributions of any kind welcome!