问题
Currently in my .scss
file I have
.grid_pic {
width : $width-grid;
background : transparent url('/img/exemple_bg.png') 0 0 repeat;
}
Is there a way of removing the /img/
and to define a variable, OR a configuration files that tells to prefix all the images with the value I want ?
So the day we decide to serve our images via CDN, we just have to change 1 config line from /img/
to http://cdn.example.com/
instead of changing all the Url of the images ?
How would you achieve that ? (a variable or is there already a config for that ?)
Thanks.
回答1:
Try the interpolation syntax along with a variable:
background: url(#{$path_variable_name}/site/background.jpg);
回答2:
did you try with image-url function ?
http://compass-style.org/reference/compass/helpers/urls/#image-url
来源:https://stackoverflow.com/questions/12583396/is-there-a-way-to-prefix-the-url-of-an-image-referenced-in-scss-in-case-of-cdn