documentcloud/jammit — Issue #219: MHTML/base_url and asset_host/asset_path + CDN
Author: dpehrson
Created: 2012-02-13 15:29:28+00:00
State: open

Howdy,

I'm not really sure how to classify this as I'm not yet sure whether it's a bug, a feature request, or simply me attempting to use jammit beyond the way it was designed, but here goes...

I run a website that

1. Uses Data-URI/MHTML asset embedding.
2. Serves it's assets out of a CloudFront distribution with multiple hostnames by using the Rails asset_host configuration.
3. Busts caches by including part of the deployed commit hash in the URL by using the Rails asset_path configuration.
4. Calls Jammit.package! via a Rake task on each deploy.

This results in Jammit asset includes as such:

```

```

The problem I have is that MHTML document's don't work because:

1. At the time the Rake task calls Jammit.package! I don't know what the base_url will be because it is determined by the combination of asset_host and asset_path configuration of the MHTML stylesheet itself.
2. Even if I set a base_url directly to where the stylesheet will be (without the right hostname), the MHTML stylesheet will load, but the embedded assets won't because it appears that Jammit doesn't seem to utilize my asset_host and asset_path configuration options when generating paths, so it has no hope of generating a URL that matches where the MHTML stylesheet is loaded from.

The first problem is something that I can likely find a way to work-around, even if it's hackish, but I'm not sure I can do anything about the second one without changing Jammit itself.

Is there any way I can make this work? If not is this something Jammit sees as "fixable? Or should I start looking at an alternate solution? (I hope not, I love Jammit!)

Thanks in advance, and I hope this isn't an inappropriate place for asking this.