Search code examples
sasscdnspritecompass

Compass Sprite Generation while referencing a CDN


I'm trying to Compass's sprite generation to serve images for IE7. I want to serve the sprite image file from my CDN, so I need to output a different url that is supplied by the sprite_url helper. The sprite_url helper outputs:

url('//web/images/icons/fallback/sprites-s0b478f635b.png')

I want it to output:

url('//images.[DOMAIN].com/images/icons/fallback/sprites-s0b478f635b.png')

It would be great if I could find a way to output the path relative to my images directory, or even just the file name of the generated sprite image.

Is there any way to do this?


Solution

  • I figured it out. Needed to change the http_generated_images_path constant in my config.rb file. I changed it to read:

    http_generated_images_path = "//images.[DOMAIN].com//images"
    

    Then I was able to output the correct url like this:

    $icons: sprite-map("icons/fallback/sprites/*.png");
    
    %sprite {
        background-image: sprite-url($icons);
        background-repeat: no-repeat;
    }