【问题标题】:Compass set .css output path to same location as .scss指南针将 .css 输出路径设置为与 .scss 相同的位置
【发布时间】:2013-09-11 00:08:57
【问题描述】:

我将编译后的 .css 文件放在我的应用程序的多个不同目录中,而我之前使用的 Sass 编译器只是将 .scss 文件编译为它们所在目录中的 .css 文件。

Compass 似乎需要一个您可以配置的“输出”目录,所有已编译的 .css 文件都会转到该目录,并且它只监视一个文件夹。

如何告诉 Compass 简单地编译到 .scss 文件的位置?

【问题讨论】:

    标签: css sass compass-sass


    【解决方案1】:

    愚蠢的我(然后)。指南针也这样做。只需为您的项目选择最高父文件夹作为config.rb 文件中的sasscss 目录,compass 将递归循环并在它找到的任何目录中将 css 编译为 sass。

    sass_options = {:cache_location => "./temp/.sass-cache"}
    http_path = "/"
    css_dir = "therootdirectory"
    sass_dir = "therootdirectory"
    images_dir = "therootdirectory/assets/images/sprites"
    javascripts_dir = "javascripts"
    

    【讨论】:

      【解决方案2】:

      Compass 使用名为 config.rb 的 ruby​​ 配置文件。用户可以在其中设置资产的各种路径、输出的样式以及 CSS 输出的路径。

      指南针网站上的文档:http://compass-style.org/help/tutorials/configuration-reference/

      这是我通常用于项目的示例,它将我的 CSS 编译到与 SCSS 不同的位置。如果您希望它在同一个地方,您可以使用. 作为路径(一个句点),这将告诉它编译到与您使用命令行watch 的目录相同的目录中。

      # Set this to the root of your project when deployed:
      http_path = "/www/"
      sass_dir = "sass"
      images_dir = "../www/lib/cssimgages"
      javascripts_dir = "../www/lib/js"
      fonts_dir = "../www/lib/fonts"
      css_dir = "../www/lib/css"
      
      # 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 = :compact
      

      不过,我确实同意其他一些 cmets。您的 HTTP 请求应保持尽可能低,可能仅引用一个样式表用于移动优先样式,而另一个样式表用于媒体查询中的样式。但这并不能回答你的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-02
        • 1970-01-01
        相关资源
        最近更新 更多