我不确定我做错了什么 - 我正在尝试使用Compass / Sass生成精灵表。我有一个非常常见的文件夹结构:
- www
+ config.rb
- img
- common
- team
+ team-member1.jpg
+ team-member2.jpg (etc)
- scss
- global
- _utilities.scss (etc)
我的config.rb文件位于根www目录中。以下是该文件的内容:
require 'compass/import-once/activate'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "img"
javascripts_dir = "js"
fonts_dir = "fonts"
output_style = :nested
environment = :development
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
line_comments = false
color_output = false
preferred_syntax = :scss
以下是我输入的用于生成精灵表的内容:
@import "compass/utilities/sprites";
@import "common/team/*.jpg";
@include all-team-sprites;
我尝试过各种各样的方法。我遗漏了指南针/实用程序/精灵导入。我在第二个@import语句中更改了文件夹目录。我尝试了以下所有变体:
@import "../img/common/team/*.jpg";
@import "img/common/team/*.jpg";
@import "/common/team/*.jpg";
@import "common/team/*.jpg";
没有任何作用。这是我从Codekit获得的错误: Compass无法编译项目中的一个或多个文件:
error styles.scss (Line 47 of _utilities.scss: File to import not found or unreadable: common/team/*.jpg.
Load paths:
/Applications/AMPPS/www/mysite/www/scss
/Applications/CodeKit.app/Contents/Resources/engines/compass/compass-core/stylesheets
/Applications/AMPPS/www/mysite/www/scss
Compass::SpriteImporter)
overwrite styles.css
答案 0 :(得分:3)
Sprites仅适用于PNG,因为与JPG不同,它是一种无损图像压缩格式 实际上,由于第二次压缩而创建精灵地图,已经压缩的JPG图像再次失去质量。