I am trying to deploy our images to a cdn. Currently the css has relative paths to images on our site. These paths will need to support the CDN image location. Does anyone have advice on how I can do this?
Or if anyone has a good tutorial on deploying to a CDN.
This is how I ended up accomplishing this.
- I used SASS - http://sass-lang.com/
- I have a mixin called cdn.scss with content like $image_path: "/images/";
- Import that mixin in the sass style @import "cdn.scss"
- Update image paths as such: background: url($image_path + "image.png");
- On deployment I change the $image_path variable in the mixin.scss and then rerun sass
UPDATE
We use bash to update the file
cat > preprocess/sass/_cdn.scss <<EOT
\$image_path: "//CDN_URL/";
Example code in the _cdn.scss
$image_path: "/public/images/";
Then it works by default locally, but on production push, we run the bash script to update using the cdn location