Skip to content

Conversation

@ThanatWongsamut
Copy link

@ThanatWongsamut ThanatWongsamut commented Jul 1, 2024

Add Bundle Size

ViteBuildStatsPlugin

  • Added bundleFiles and bundleSize in viteBuildStatsPlugin.
  • bundleFiles is a record of all files generated from the build process, stored as:
    • key: file name
    • value: file size in bytes
  • bundleSize is the total size of all files contained in bundleFiles.

WebpackBuildStatsPlugin

  • Added bundleFiles and bundleSize in WebpackBuildStatsPlugin.
  • bundleFiles is a record of all files generated from the build process, stored as:
    • key: file name
    • value: file size in bytes
  • bundleSize is the total size of all files contained in bundleFiles.

Result

Bundle Result from devfeedback Result from bundle analyzer
Vite image image
Webpack image image

Notes

  • bundleFiles will contain all files such as *.js, *.LICENSE.txt, .css, .svg.
  • File sizes in Vite may not be the same as the output from the analyzer because the analyzer gets bundle info from Rollup, but I get it from the actual file in disk with fs.

for (const [fileName, assetInfo] of Object.entries(bundle)) {
const filePath = path.join(options.dir || '', fileName);
try {
const stats = await fs.stat(filePath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much slower has this plugin become? Did you do any benchmarks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants