Skip to content
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: opt-in option to compress public assets using gzip and br #449

Merged
merged 7 commits into from
Aug 30, 2022

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 30, 2022

πŸ”— Linked issue

#69

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR enables public (and pre-rendered) assets compression with opt-in flag compressPublicAssets.

When this flag is enabled, after copying all public assets and prerendering, public asset plugin creates compressed version of assets using gzip (.gz) and brotli (.br).

In runtime, the static asset handler checks the incoming request's accept-encoding header and if the browser supporting it, tries to search for the compressed assets in the manifest.

Because this feature does compression on build time, it works universally for all presets as long as they allow responding binary data and has zero overhead on runtime performance.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Aug 30, 2022

Codecov Report

Merging #449 (99cbf50) into main (d1d1015) will increase coverage by 0.32%.
The diff coverage is 81.69%.

❗ Current head 99cbf50 differs from pull request most recent head c9a4884. Consider uploading reports for the commit c9a4884 to get more accurate results

@@            Coverage Diff             @@
##             main     #449      +/-   ##
==========================================
+ Coverage   53.59%   53.92%   +0.32%     
==========================================
  Files          54       54              
  Lines        3502     3544      +42     
  Branches      370      379       +9     
==========================================
+ Hits         1877     1911      +34     
  Misses       1268     1268              
- Partials      357      365       +8     
Impacted Files Coverage Ξ”
src/types/nitro.ts 100.00% <ΓΈ> (ΓΈ)
src/rollup/plugins/public-assets.ts 85.32% <81.42%> (-2.92%) ⬇️
src/options.ts 42.85% <100.00%> (+0.26%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0 pi0 changed the title feat: opt-in option to compress public assets feat: opt-in option to compress public assets using gzip and br Aug 30, 2022
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.

1 participant