1

这是我的 SCSS:

@import "compass";

$spriteretina: sprite-map("sprite-retina/*.png");
$sprite: sprite-map("sprite/*.png");  

@mixin retina-sprite($name) {
    background-image: sprite-url($sprite);
    background-position: sprite-position($sprite, $name);
    background-repeat: no-repeat;
    display: block;
    height: image-height(sprite-file($sprite, $name));
    width: image-width(sprite-file($sprite, $name));
    @media (-webkit-min-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 2) {
        // Workaround for https://gist.github.com/2140082
        @if (sprite-position($sprite, $name) != sprite-position($spriteretina, $name)) {
            $ypos: round(nth(sprite-position($spriteretina, $name), 2) / 2);
            background-position: 0 $ypos;
        }
        // Set image size to the orginal size of the image
        @include background-size(ceil(image-width(sprite-path($spriteretina)) / 2) auto);
        background-image: sprite-url($spriteretina);
    }
}

.logo {
    background-image: sprite-url($spriteretina);
}

当我尝试编译时,出现此错误:

PS C:\part\to\Website> compass compile
unchanged Frontend/img/icons-s49ccc64d2b.png
unchanged Frontend/img/sprite-s8e1b03f13e.png
Errno::ENOENT on line 28 of C: No such file or directory - Frontend/img/sprite-retina-sdc5ec023dc.png
Run with --trace to see the full backtrace

我用完整的回溯运行它并得到这个:

Errno::ENOENT on line 28 of C: No such file or directory - Frontend/img/sprite-retina-s7f5af5584d.png
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:28:in `open'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:28:in `get_size_for_png'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:21:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:21:in `size'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:50:in `image_dimensions'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:4:in `image_width'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:106:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:106:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/operation.rb:74:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:362:in `visit_media'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:68:in `perform_arguments'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:261:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:318:in `visit_rule'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:318:in `visit_rule'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `visit_import'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `visit_import'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:126:in `visit_root'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:7:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:7:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/root_node.rb:20:in `render'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/engine.rb:315:in `_render'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/engine.rb:262:in `render'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:140:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:139:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/logger.rb:45:in `red'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:138:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:118:in `compile_if_required'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:103:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `each'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:100:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/update_project.rb:45:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/base.rb:18:in `execute'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/project_base.rb:19:in `execute'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:30
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:44:in `call'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:44
  C:/ruby187/bin/compass:19:in `load'
  C:/ruby187/bin/compass:19

对我来说,它似乎是在创建精灵文件之前尝试读取它。这给出了一个错误。但为什么我会遇到这种行为?我能做些什么来解决它?

我试图删除所有 .sass-cache 文件,重命名我的文件夹。但没有运气。

4

1 回答 1

1

我用一种解决方法解决了这个问题。这很简单,只需在使用 sprite 的 mixin之前添加一个选择器,如下所示:

.fixesabugwithcompass {
    background-image: sprite-url($sprite-retina-sprites);
}

每次在 mixin 中使用 Compass 生成图像时,仍然存在问题。此处报道: https ://github.com/chriseppstein/compass/issues/897

于 2012-11-13T10:00:50.813 回答