Create-react-app: Display difference from the previous build in filesize

Created on 2 Aug 2016  路  13Comments  路  Source: facebook/create-react-app

Update: The issue is claimed by @elijahmanor.

Seems like a nice thing to do.
We can read the files before clearing the build folder.

It could look like this:

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  48.73 KB (+2.12 KB)  build/static/js/main.42e82b08.js
  289 B                build/static/css/main.9a0fe4f1.css

(Right now we display the build size but not the delta.)

Most helpful comment

I can work on that tonight

All 13 comments

If you intend to work on this please comment here so multiple people don鈥檛 grab this at the same time.

Relevant code in the build script.

Here鈥檚 where we clean the folder so you鈥檒l want to read sizes before that.

Read how to contribute.

I can work on that tonight

Great! Let me know if you have any troubles, happy to walk you through the code.

Sorry for stepping in, I felt like I was able to take this task, too... :smile:

I'm wondering how the hash of the old file could be retrieved...

@kripod

Hi, thanks but I think this is not a very nice way to contribute.
I believe I posted above:

Update:
The issue is claimed by @elijahmanor.

I also wrote:

If you intend to work on this please comment here so multiple people don鈥檛 grab this at the same time.

Then @elijahmanor commented that he plans to work on this, and I wrote:

Great! Let me know if you have any troubles, happy to walk you through the code.

I appreciate the intention to contribute but this just won鈥檛 work well if everyone keeps grabbing issues claimed by somebody else.

There are other issues, like https://github.com/facebookincubator/create-react-app/issues/73, that need somebody to work on them. I鈥檇 appreciate if you could look at that issue instead.

If @elijahmanor later decides he鈥檇 rather not work on this, I鈥檇 be happy to reassign this to you.
Thank you!

I'm sorry to interrupt, and will wait on the answer of @elijahmanor. Anyway, old build hashes could be retrieved from a generated manifest file or deterministically. Which method should be preferred?

I should鈥檝e made a larger heading for this in the original post (I鈥檒l fix that now).
Maybe should introduce a GitHub label for claimed issues.

That sounds great, I apologize I didn't notice that before trying to contribute...

Anyway, old build hashes could be retrieved from a generated manifest file or deterministically. Which method should be preferred?

No problem, it鈥檚 my fault, I should make the guidelines clearer.


As for your question, is there a particular reason webpack for this at all? I鈥檇 probably do the easy thing and just read sizes of all css/js files deeply inside build directory before removing it.

That sounds like a plan, although that way, it'd read some old files from the disk unnecessarily. I prefer comparing only the newly-written files with their old counterparts. A regex could be used to remove hash strings before comparing file names.

On a second thought, you're right: reading old files with unknown hashes deterministically is a painful task. Premature optimization is the root of evil. :blush:

yes, that is the route that I took tonight... recursively found files in build folder and removed the hashes to build an object map of previous sizes that can be used later on to compare delta sizes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrice727 picture adrice727  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

barcher picture barcher  路  3Comments

ap13p picture ap13p  路  3Comments

onelson picture onelson  路  3Comments