👩🔬 Webpack Dependency Size Plugin
Webpack plugin to get an overview of bundled dependencies and their size.
:raising_hand: Why?
- 📦 Only Dependencies Get insight into the blackbox!
- 🔥 Fast Only analyzes the bare minium!
- 👀 JSON Output Formatted, sorted, and portable!
- 🙈 No distractions Ignore application code!
:rocket: Install
npm i -D webpack-dependency-size
👩🏫 Basic Usage
In your Webpack config:
const DependencySize = require('webpack-dependency-size');
module.exports = {
...,
plugins: [
new DependencySize()
]
};
Options
Pass in an options object to configure:
new DependencySize({
gzip: true
})
outputPath
(dependency-size.json
) JSON output path relative to Webpack output directory (output.path
)gzip
(false
) Calculate gzipped sizeindent
(2 spaces) JSON output indentation
📋 Output
Schema
type File = {
filepath: string;
size: string;
reasons: string[];
};
type Report = {
dependencyPath: string;
size: string;
files: File[];
}[];
Example
Tip: If the output is too large, I recommend using fx to navigate the JSON
[
{
"dependencyPath": "./node_modules/axios",
"size": "40.15 KB",
"files": [
{
"filepath": "./node_modules/axios/lib/utils.js",
"size": "8.61 KB",
"reasons": [
"./node_modules/axios/lib/adapters/xhr.js",
...
]
},
...
]
},
{
"dependencyPath": "./node_modules/lodash",
"size": "25.37 KB",
"files": [
{
"filepath": "./node_modules/lodash/_deburrLetter.js",
"size": "3.33 KB",
"reasons": [
"./node_modules/lodash/deburr.js"
]
},
...
]
},
...
]
👨👩👦👦 Related
💼 License
MIT