Retina-Sprites-for-Compass icon indicating copy to clipboard operation
Retina-Sprites-for-Compass copied to clipboard

sprite-url function generates sprite image several times

Open yoonsy opened this issue 10 years ago • 3 comments

I'm developing on Rails framework ver 3.2.13.

On development environment, sprite-url function generates sprite image several times. So, it takes long time to precompile scss file.

For example, application.scss file looks like below.

@import "retina-sprites";
$sprites: sprite-map('to_sprite/*.png', $spacing: 1px);
$sprites2x: sprite-map('to_sprite/*.png', $spacing: 2px);

#logo {
  @include retina-sprite(logo);
}
#icon1 {
  @include retina-sprite(icon1);
}
#icon2 {
  @include retina-sprite(icon2);
}

I used retina-sprite mixin 3 times.

It causes generating sprite image 3 times.

yoonsy avatar Oct 06 '14 04:10 yoonsy

Hmmm, is this using the master branch or 2.0 branch? Just curious because i'm about to merge 2.0 into master in the next few days. To be honest i'm not sure what's going on causing it to load 3 times. I've been using icon fonts lately so I haven't been using this for new projects.

AdamBrodzinski avatar Oct 07 '14 21:10 AdamBrodzinski

@AdamBrodzinski sprite-url() call generates the sprite, every time you call it. I have solved this issue by using global :( variable.

$sprite-url: sprite-url($icons);
@mixin _retina-sprite ...
  background-image: $sprite-url;

Same for 2x sprite. Btw, why don't you use background: shortcut instead of applying each property individually?

DmitryGonchar avatar Mar 26 '15 13:03 DmitryGonchar