Skip to content

Compress with gz and br on build/precompile? #101

Answered by ElMassimo
evenreven asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @evenreven!

Compressing assets at build time is not as relevant as in the past—many CDNs and edge services will automatically serve compressed assets.

This is why the feature is not in core Vite.js, it would unnecessarily increase the bundle size and build size for something most users will already get from their hosting providers.


If you still need this behavior, there are good news though 😃

Since Vite.js is built on top of Rollup, plugins such as rollup-plugin-brotli and rollup-plugin-gzip work out of the box.
You may combine them to generate both gz and br versions of each asset, or add rollup-plugin-gzip once per format.

There's also vite-plugin-compress, but it compresses files i…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@evenreven
Comment options

@evenreven
Comment options

@ElMassimo
Comment options

@evenreven
Comment options

Answer selected by ElMassimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants