documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.io/jammit/
MIT License
1.16k stars 197 forks source link

Possibility to change where CSS url()s is loaded from, to enable CDN for CSS loaded images #222

Closed PatrickLef closed 7 years ago

PatrickLef commented 12 years ago

This makes it possible to set a host for your assets, which will then be used for the CSSs to change url(/foobar.jpg) to url(http://cdn.example.com/foobar.jpg). Which I needed to be able to put larger images that I don't want to base64 encode in my CDN.

With this came 2 more problems.

  1. Cloudfront don't support setting a Access-Control-Allow-Origin header on your files, which means that fonts still have to be loaded from your domain. Therefor I added a setting where you can set which file extensions that should not be loaded from the asset host.
  2. While it was possible to set file extensions that shouldn't be loaded from the asset host, that also meant that fonts included from CSS using /font.woff would be loaded from the asset hosts root instead of the web site. Therefor I had to add a setting where you can set where the web host is.

If you find this patch interesting, I would gladly update the docs and write som specs for it!

hemang commented 12 years ago

cool stuff. Interesting!