-
First of all, thank you for saving my project from the time drain that is webpack! 😉 One thing webpacker does right, is that it outputs a .gz and a .br compressed copy of every precompiled asset (excluding fonts and images), which is a very nice batteries included-type feature. Vite doesn't do this on its own. There are currently two plugins that aim to help, but they don't really work due to recent changes in vite. But isn't it probably just as good to give the task to this gem, i.e. rake (or EDIT: I just realised browsing the webpacker source code that the compression is done by webpack and not rake. So that might pose a problem? Honestly I'm surprised vite doesn't offer this option as default. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
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 There's also Check out the |
Beta Was this translation helpful? Give feedback.
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
androllup-plugin-gzip
work out of the box.You may combine them to generate both
gz
andbr
versions of each asset, or addrollup-plugin-gzip
once per format.There's also
vite-plugin-compress
, but it compresses files i…