编译单个样式表时出现罗盘错误:"Individual stylesheets must be in the sass directory"

Compass Error When Compiling Individual Stylesheets: "Individual stylesheets must be in the sass directory"

我在使用 Compass 编译单个样式表时遇到问题。我可以使用 compass compile 来处理所有文件,并使用 compass watch 来监视更改。但是当我尝试将特定文件分配给 compass compile 时,出现以下错误:

Individual stylesheets must be in the sass directory

我的目录结构:

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 文件。

我做错了什么?

这不是一个完美的解决方案,但至少可以让您继续前进。这可能是由于指南针中的一些错误导致 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

构建单独的 sass 文件