SCSS和Compass CLI配置

时间:2013-02-13 00:09:10

标签: compass-sass sass

如何在使用sass CLI时配置Compass?

基本上我是设置images_dir属性,这是我一直使用的命令:

sass 
    --compass
    path/to/input.scss
    path/to/output.css

我试过了:

sass 
    --compass
    -c path/to/config.rb
    path/to/input.scss
    path/to/output.css

输出:

WARNING on line 1 of path/to/config.rb:
This selector doesn't have any properties and will not be rendered.
Syntax error: Invalid CSS after "image_dir ": expected selector, was "= "test""
    on line 1 of path/to/config.rb

很明显,使用-c命令时compass compile的工作方式不同。

sass 
    --compass
    --images-dir path/to/images
    path/to/input.scss
    path/to/output.css

输出:

OptionParser::InvalidOption: invalid option: --images-dir

同样如上所述。

我尝试使用compass compile,但我没有项目目录。

compass compile 
    --images-dir path/to/images
    path/to
    path/to/input.scss

输出:

You must compile individual stylesheets from the project directory.

还试过这个:

compass compile 
    path/to

输出:

Nothing to compile. If you're trying to start a new project, you have left off the directory argument.

config.rb刚刚包含:

images_dir = "test"

1 个答案:

答案 0 :(得分:2)

compass compile读取config.rb文件以进行配置。

以下是我使用的示例项目设置,从config.rb文件开始:

require "susy"

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "public/css"
sass_dir = "private/scss"
images_dir = "public/images"
http_images_path = "/images"

output_style = :expanded # or :nested or :compact or :compressed

# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = true

我的项目设置如下:

private/scss    # scss files. I use a main file that handles imports itself
public/images   # images
public/css      # built css here
config.rb       # contents included above

要构建它,我在项目的根文件夹中运行以下命令:

bundle exec compass compile private/scss/layout.scss