bundlesize icon indicating copy to clipboard operation
bundlesize copied to clipboard

Allow default file size to ensure no big files are added later

Open martinkutter opened this issue 5 months ago • 0 comments

Do you want to request a feature or report a bug? Bug/Feature

What is the current behavior? It is not possible to ensure that a limit is set for each file. So over time may huge chunks are added unintentionally. This is because files are matched multiple times and order does not matter.

Example:

assets/
  file.js (100KB)
  otherFile.js (1KB)

I want to set a limit for a specific file, and a default limit for all other files:

"bundlesize": [
        {
            "path": "./assets/file.js",
            "maxSize": "120 kB"
        },
        {
            "path": "./assets/*.js",
            "maxSize": "2 kB"
        }
    ],

But the Result ist:

PASS  ./assets/file.js: 100KB < maxSize 120KB (gzip) 
FAIL ./assets/file.js: 100KB > maxSize 2KB (gzip) 
PASS ./assets/otherFile.js: 1KB < maxSize 2KB (gzip) 

If this is a expected behaviour, may there should be an option/solution to achieve the use case. Otherwise I suggest to do not match files multiple times based on order.

martinkutter avatar Jan 11 '24 18:01 martinkutter