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

これを回避策で解決しました。スプライトを使用する mixin の前に、次のようにセレクターを作成するだけです。

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

コンパスが mixin で使用されるたびに画像を生成するという問題はまだあります。ここで報告されています: https://github.com/chriseppstein/compass/issues/897

于 2012-11-13T10:00:50.813 に答える