我一直在研究 Compass,我看的越多,感觉就越像应该编写 CSS 的方式。作为一个测试用例,我想在我的一个 CakePHP 项目中使用它。不幸的是,我在初始配置时遇到了一些问题。具体来说,将资源放在正确的位置并在编译的 CSS 中正确引用。
我正在我的目录中创建一个:stand_alone
项目。/app
嗯,这就是我想做的。指南针似乎不喜欢那样。在创建项目时,我已经告诉它将 css、图像和 js 放在哪里,实际上,这些资源确实放在了正确的目录中。不幸的是,因为我没有在 webroot 中创建目录,所以在编译时资源被错误地引用。
我正在app/
使用以下命令在我的 CakePHP 目录中创建 Compass 项目:
$ compass -f blueprint --sass-dir sass --css-dir webroot/css/ --images-dir webroot/img/ --javascripts-dir webroot/js/ --output-style compact .
但是,编译后的 CSS 希望将蓝图的showgrid.png
图像引用为:
url('/webroot/img/grid.png?1264969358')
我想这是一个非常可预测的结果,但我不知道如何让编译后的 CSS 引用正确的/img/grid.png?whatever
路径。这甚至可能吗?我是否被迫直接在我的 webroot 中创建我的 Compass 项目?
谢谢。
更新
我的config.rb
文件内容:
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "webroot/css"
sass_dir = "sass"
images_dir = "webroot/img"
http_images_path = "/img"
javascripts_dir = "webroot/js"
output_style = :compact