【问题标题】:Compile multiple stylesheets with Compass, different output style and ".min" file name使用 Compass、不同的输出样式和“.min”文件名编译多个样式表
【发布时间】:2013-07-23 13:52:24
【问题描述】:

总结:使用 Compass,需要编译两次不同的输出样式和文件名的 SASS 样式表。

我有这个作为我的 config.rb:

http_path           = "/"
css_dir             = "assets/css"
sass_dir            = "assets/sass"
# …more stuff… #
output_style        = :expanded

完美编译

assets 
┗ sass
   ┣ style1.scss
   ┗ style2.scss

assets 
┗ css
   ┣ style1.css
   ┗ style2.css

我需要完成的是这样的输出:

assets 
┗ css
   ┣ style1.css
   ┣ style1.min.css
   ┣ style2.css
   ┗ style2.min.css

“.min.css”文件显然包含缩小的 CSS。

所以我想我需要想出类似的东西:

on_stylesheet_saved do |filename|
    # switch output_style to :compressed
    # compile again and include ".min" into file name
end

谁能为我提供一个基本示例来说明如何实现这一目标? 到目前为止还没有弄乱 ruby​​,但是通过我一直在做的关于这个主题的所有阅读,我有了一个基本的理解。 ;) 非常感谢!

【问题讨论】:

    标签: compilation config compass-sass minify


    【解决方案1】:

    我建议Yeoman,或自定义Grunt 脚本。如果您更注重 Ruby,也可以使用 Rake

    【讨论】:

      【解决方案2】:

      (因代表无法评论)

      要回答 Kevin Suttle,gulp 也可以完成这项工作。这有点像 grunt,但在 gulp 中,你得到的是代码而不是配置,而 grunt 主要是配置,没有(或几乎没有)代码。

      许多文章说人们在一天内学会了 grunt,而他们只花了一个小时来学习 gulp。

      这取决于你。

      PS:是的,该帖子是 2013 年发布的,但回答它可能会对遇到相同或类似问题的人有所帮助。

      【讨论】:

        猜你喜欢
        • 2015-01-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-24
        • 1970-01-01
        相关资源
        最近更新 更多