All Projects → robertknight → Webpack Bundle Size Analyzer

robertknight / Webpack Bundle Size Analyzer

Licence: isc
A tool for finding out what contributes to the size of Webpack bundles

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Webpack Bundle Size Analyzer

Redux Cnode
react+react-router+redux+es6+antd-mobile+webpack版本的Cnode
Stars: ✭ 96 (-93.02%)
Mutual labels:  webpack
Stack Source Map
Add source map support for error stack (Chrome only)
Stars: ✭ 98 (-92.88%)
Mutual labels:  webpack
React Uport Box
Truffle, Webpack, React, Redux boilerplate with routing and authentication via a UPort.
Stars: ✭ 99 (-92.81%)
Mutual labels:  webpack
Fork Ts Checker Webpack Plugin
Webpack plugin that runs typescript type checker on a separate process.
Stars: ✭ 1,343 (-2.4%)
Mutual labels:  webpack
Simple React Calendar
A simple react based calendar component to be used for selecting dates and date ranges
Stars: ✭ 97 (-92.95%)
Mutual labels:  webpack
Nodeppt
This is probably the best web presentation tool so far!
Stars: ✭ 9,589 (+596.88%)
Mutual labels:  webpack
React From Scratch
Building a Modern React App from Scratch in 2021
Stars: ✭ 87 (-93.68%)
Mutual labels:  webpack
Cloudflare Workers Webpack Boilerplate
A superbly simple, minimal-config template for building, bundling and deploying Cloudflare Workers with Webpack 🚀
Stars: ✭ 101 (-92.66%)
Mutual labels:  webpack
Vuedemo sell eleme
ele by vue2.x 🐧
Stars: ✭ 1,349 (-1.96%)
Mutual labels:  webpack
Jhipster Microservices Example
JHipster Microservices Example using Spring Cloud, Spring Boot, Angular, Docker, and Kubernetes
Stars: ✭ 100 (-92.73%)
Mutual labels:  webpack
Uglifyjs Webpack Plugin
[deprecated] UglifyJS Plugin
Stars: ✭ 1,343 (-2.4%)
Mutual labels:  webpack
Gas Webpack Plugin
Webpack plugin for Google Apps Script
Stars: ✭ 97 (-92.95%)
Mutual labels:  webpack
Art Template
High performance JavaScript templating engine
Stars: ✭ 9,554 (+594.33%)
Mutual labels:  webpack
Eleventy Starter
An 11ty starter project.
Stars: ✭ 97 (-92.95%)
Mutual labels:  webpack
Webpack Wordpress
Build Wordpress themes using Webpack and Hot Module Reloading
Stars: ✭ 100 (-92.73%)
Mutual labels:  webpack
Vuerecipe
A recipe for using Buffalo & Vue.js
Stars: ✭ 95 (-93.1%)
Mutual labels:  webpack
Ng Boot Oauth
oauth2 demo with angularjs and springboot
Stars: ✭ 99 (-92.81%)
Mutual labels:  webpack
Wordless
All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
Stars: ✭ 1,374 (-0.15%)
Mutual labels:  webpack
Asf Ui
The official web interface for ASF
Stars: ✭ 100 (-92.73%)
Mutual labels:  webpack
Simpacker
Use modern JavaScript build system in Rails.
Stars: ✭ 100 (-92.73%)
Mutual labels:  webpack

Webpack Bundle Size Analyzer

Build Status

A small utility to help you find out what is contributing to the size of your Webpack bundles.

Webpack has a JSON output mode which produces detailed machine-readable information about everything that has been included in a generated bundle.

This output is produced by running webpack --json. This tool analyzes the resulting JSON output and displays a tree of packages that were included in the bundle, ordered by the size of all the used modules.

For further reading on reducing the size of Webpack bundles, see their optimization guide

Usage

There are 2 ways to use this tool:

  1. As a command line application
  2. As a webpack plugin

CLI Usage

Assuming you have the webpack CLI command installed locally in your project:

npm install -g webpack-bundle-size-analyzer
node_modules/.bin/webpack --json | webpack-bundle-size-analyzer

If you have webpack installed globally then the first part of this command will be just webpack --json instead.

When run on react-testing for example, it produces this output, where <self> refers to the size of the bundle's own code.

react: 641.95 kB (55.3%)
  <self>: 641.95 kB (100%)
chai: 125.8 kB (10.8%)
  deep-eql: 7.51 kB (5.97%)
    type-detect: 2.72 kB (36.2%)
      <self>: 2.72 kB (100%)
    <self>: 4.79 kB (63.8%)
  assertion-error: 2.29 kB (1.82%)
    <self>: 2.29 kB (100%)
  <self>: 116 kB (92.2%)
flummox: 73.46 kB (6.33%)
  flux: 9.01 kB (12.3%)
    <self>: 9.01 kB (100%)
  eventemitter3: 5.94 kB (8.08%)
    <self>: 5.94 kB (100%)
  uniqueid: 947 B (1.26%)
    <self>: 947 B (100%)
  object-assign: 484 B (0.643%)
    <self>: 484 B (100%)
  <self>: 57.12 kB (77.8%)
q: 58.84 kB (5.07%)
  <self>: 58.84 kB (100%)
...
<self>: 195.57 kB (16.9%)

Plugin Usage

Description

When using the plugin version of this library, a file will be written to a location of your choice (when you run your webpack build). The file contents will be a list of the packages in your bundle (sorted in descending order). Each line will contain the name of a package, along with it's file size, and the percentage of space it takes up in your bundle.

Plugin Installation

Install this library as a development dependency to your webpack project:

npm install --save-dev webpack-bundle-size-analyzer

Import your plugin at the top of your webpack.config.js file:

Old School:

var WebpackBundleSizeAnalyzerPlugin = require('webpack-bundle-size-analyzer').WebpackBundleSizeAnalyzerPlugin;

New School:

import { WebpackBundleSizeAnalyzerPlugin } from 'webpack-bundle-size-analyzer';

Now in your webpack's plugin section, start using this plugin:

{
  {...topOfConfig}
  plugins: [
    new WebpackBundleSizeAnalyzerPlugin('./reports/plain-report.txt')
  ]
  {...bottomOfConfig}
}

Example Plugin Output

Using the above plugin configuration, the following file will be written:

<webpack-output-path>/reports/plain-report.txt:

marked: 27.53 KB (14.9%)
lru-cache: 6.29 KB (3.40%)
style-loader: 717 B (0.379%)
<self>: 150.33 KB (81.3%)

Important Note About Minified Code

If you minify/compress your code using the approach recommended in the Webpack documentation, which is to use the UglifyJS plugin, be aware that this tool will report the sizes of modules before they are minified. This is because the statistics generated by webpack --json do not take account of plugins that operate on the bundle as a whole.

Knowing the sizes of dependencies before they are minified can still be useful to get an idea of how much different dependencies are responsible for size of your minified bundle, but be aware that it can be misleading. This is because some libraries compress better than others.

If instead you minify modules in your bundle individually using a loader (eg. the UglifyJS loader), the stats output by webpack --json will show minified sizes. If you want to get a better idea of the sizes of different dependencies after they are minified, you can temporarily remove the UglifyJS plugin and replace it with the UglifyJS loader instead before running webpack --json | webpack-bundle-size-analyzer.

The reason that using a plugin, rather than a loader, is the recommended approach in Webpack is that compression is better if applied to the whole bundle rather than to individual source files one at a time.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].