preactjs / compressed-size-action

GitHub Action that adds compressed size changes to your PRs.
https://github.com/marketplace/actions/compressed-size-action
MIT License
603 stars 84 forks source link

Report aggregate stats by folder and file type? #111

Open slorber opened 1 week ago

slorber commented 1 week ago

I'm using this project on Docusaurus, a static site generator, to monitor the build output size

Example PR comment: https://github.com/facebook/docusaurus/pull/10470#issuecomment-2324697764

Monitoring by file size is great, but in our case, we emit too many output files to monitor them all without creating noise, so I only added a "representative" list of output files.

What would be a great addition for us would be to have the ability to compare the before/after size of a whole folder. Eventually be able to break it down by file type, so that we could detect if JS, CSS, or HTML total output size increases after a PR.

I'm wondering if this could be part of this project, or if it's out of scope and should be a separate tool.

rschristian commented 1 week ago

Interesting, would you only want the folder and file types inside of it, replacing individual files altogether then? Something like the following maybe:

Directory Type Size Change
compat/dist/foo CSS 3.53 kB -567 B (-13.83%) 👏
compat/dist/foo JS 3.44 kB -582 B (-14.46%) 👏
compat/dist/foo HTML 3.6 kB -571 B (-13.71%) 👏

Or perhaps:

Directory Type Size Change
compat/dist/foo All 9.53 kB -567 B (-13.83%) 👏
CSS 3.53 kB -567 B (-13.83%) 👏
JS 3.44 kB -582 B (-14.46%) 👏
HTML 3.6 kB -571 B (-13.71%) 👏
compat/dist/bar All 9.53 kB -567 B (-13.83%) 👏

(Ignore the nonsensical sizes that don't add up, I quickly copy/pasted from Preact 😄)

Or in addition to the existing output? Just thinking if it's a toggled either/or situation or just a new output table.


I think it would be a reasonable addition though!

slorber commented 1 week ago

Thanks!

I think a separate table makes more sense. I guess something like this could be nice, with the ability to count the number of files and the change too.

For flexibility, I'd break it down by extension and not just CSS/JS/HTML.

Folders Count Size Change
website/build1 278 (+1 ⚠ī¸) 666 kB +34 B (+0.01%)
website/build2 10 (+0) 10 kB +34 B (+0.01%)
TOTAL 288 (+1 ⚠ī¸) 676 kB +34 B (+0.01%)
ℹī¸ Break down by extension | Extension | Count | Size | Change | | :--- | :---: | :---: | :---: | | `.js` | 100 (+0) | 2 B | 0 B | | `.css` | 100 **(+1 ⚠ī¸)** | 27.9 kB | 0 B | | `.html` | 100 (+0) | 27.9 kB | 0 B | | `.jpg` | 100 (+0) | 30.2 kB | 0 B |

rschristian commented 1 week ago

For flexibility, I'd break it down by extension and not just CSS/JS/HTML.

Yeah that was just for a quick example, albeit using the names instead of the proper extension.

But this seems reasonable and I can see how many might want this. I'll take a look at this later this week if I get some time.