AdamBrodzinski / Retina-Sprites-for-Compass

A mixin for creating retina sprites with hover & active states
MIT License
233 stars 35 forks source link

sprite-url function generates sprite image several times #40

Open yoonsy opened 10 years ago

yoonsy commented 10 years ago

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.

AdamBrodzinski commented 10 years ago

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.

yoonsy commented 10 years ago

I'm using master branch's _retina-sprites.scss.

DmitryGonchar commented 9 years ago

@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?