我在使用Compass编译单个样式表时遇到问题。我可以使用compass compile
来执行所有文件,并使用compass watch
来监控更改。但是当我尝试将特定文件分配给compass compile
时,我得到以下错误:
单个样式表必须位于sass目录中
我的目录结构:
project root
- util
-- compass
--- config.rb
- www
-- css
--- [destination for .css files]
-- sass
--- [.scss files]
我的config.rb:
project_type = :stand_alone
# Set this to the root of your project when deployed:
project_path = "../../"
http_path = "www" # The path to the project when running within the web server.
css_dir = "www/css" # relative to project_path
sass_dir = "www/sass" # relative to project_path
images_dir = "www/images" # relative to project_path
javascripts_dir = "www/js" # relative to project_path
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
relative_assets = true
# generate sourcemaps
sourcemap = true
从/util/compass
文件夹运行时,以下工作正常:
compass compile
compass watch
这些不起作用:
compass compile builder.scss
compass compile ../../www/sass/builder.scss
compass compile www/sass/builder.scss
并导致错误,这可能意味着无法找到scss文件。
我做错了什么?
答案 0 :(得分:1)
这不是一个完美的解决方案,但至少可以让你前进。可能这是由指南针中的一些错误导致无效sass_path
引起的。因此,请手动设置sass_path
:
project_type = :stand_alone
# Set this to the root of your project when deployed:
project_path = "../../"
http_path = "www" # The path to the project when running within the web server.
css_dir = "www/css" # relative to project_path
sass_dir = "www/sass" # relative to project_path
sass_path = File.expand_path(File.join(project_path, sass_dir))
images_dir = "www/images" # relative to project_path
javascripts_dir = "www/js" # relative to project_path
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
relative_assets = true
# generate sourcemaps
sourcemap = true
然后您应该能够使用命令compass compile ../../www/sass/builder.scss