How do you compress your Ember.js assets at build time?


#1

Is there an accepted way for compressing Ember.js assets at build time?

I’m particularly interested in Zopfli solutions to minimize file sizes.


#2

What type of assets are you trying to compress and how? Might help anyone trying to answer propose a better solution for you.

I use Ember CLI, and it automatically concatenates and minifies my JS and CSS files for me when doing a production build, so that is what I use. There are also add-on hooks that one can attach to for a more complex and custom build process – like gzip’ing assets – as well.


#3

Gzipping HTML, CSS, and JavaScript assets are the main ones. Preferably with zopfli rather than gzip.


#4

As long as you have some HTTP/application server that can serve pre-compressed assets (i.e. ones with .gz extensions appended), then take a look at ember-cli-gzip. And for modern browsers you can use ember-cli-brotli.

I recently looked for a way to use zopfli with ember-cli-gzip. When I couldn’t find a way I wrote ember-cli-zopfli as a drop-in replacement.

There’s also ember-cli-deploy-gzip and ember-cli-deploy-brotli if you use ember-cli-deploy.


#5

There is also https://github.com/DockYard/ember-cli-deploy-compress which chooses gzip or brotli based on your config/targets.js file.