-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: include only compressible mime types #761
feat: include only compressible mime types #761
Conversation
Codecov Report
@@ Coverage Diff @@
## main #761 +/- ##
==========================================
+ Coverage 72.27% 72.30% +0.03%
==========================================
Files 57 57
Lines 5154 5157 +3
Branches 556 555 -1
==========================================
+ Hits 3725 3729 +4
+ Misses 1419 1418 -1
Partials 10 10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thanks for the PR @nathanchase and review @manniL @danielroe. I think currently, docs is not consistent with implementation. We shall maintain an explicit list (array) of supported mimes. This also allows making it easier to customize by users whereas regex is harder to extend. Also we might include webp to the list as is text based. |
@pi0 We could use https://www.npmjs.com/package/compressible, or maybe something similar that checks against a known list of compressible mime types. |
I was under the understanding that using Brotli/Gzip on .webp files would just increase the file size. I'm unable to find a clear answer to that question in my research, other than |
compressible uses mime-db, which nitro already stubs into this. AWS list, seems a great start ππΌ Let's not over complicate this.
You are right. Totally my bad. I meant SVG π€¦πΌββοΈ |
Take a look at the latest commits and see what you think. Should be good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π―
π Linked issue
https://github.com/nuxt/framework/discussions/9626
β Type of change
π Description
The code for
compressPublicAssets
was double-compressing all image types (including .jpg, .png, .gif, .webp, etc.) when it really should only be compressible static file types that are text-based. I updated the code to use the following list of MIME types, and also added it to the docs forcompressPublicAssets
:text/html
text/css
text/plain
text/xml
text/x-component
text/javascript
application/x-javascript
application/javascript
application/json
application/manifest+json
application/vnd.api+json
application/xml
application/xhtml+xml
application/rss+xml
application/atom+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-font-opentype
application/x-font-truetype
image/svg+xml
image/x-icon
image/vnd.microsoft.icon
font/ttf
font/eot
font/otf
font/opentype
π Checklist