Can SASS/Compass compile foo.scss to foo.min.css and foo.dbg.css?

大憨熊 提交于 2019-12-05 00:47:47

No it can't. I asked the same question in the mailing lists about RTL stylesheets. However, you can run compass compile using different 'config.rb' files. Try compass compile -c debug.rb.

UPDATE: Compass still can't, but Gulp can watch and generate several target css files using Sass and Compass. See https://github.com/Snugug/gulp-css-target/

I couldn't get Alireza Fattahi's answer to work because it threw errors so I found another example which works for me

http://h3r2on.com/2013/05/17/rename-css-on-compile.html

require "fileutils"

on_stylesheet_saved do |file|
  if File.exists?(file)
    filename = File.basename(file, File.extname(file))
    File.rename(file, css_dir + "/" + filename + ".min" + File.extname(file))
  end
end

You can add this to your config.

Please see https://github.com/sbspk/Prepros/issues/38

require 'fileutils'

on_stylesheet_saved do |file|

  if file.match('.min') == nil

    require 'compass'

    Compass.add_configuration(
        {
            :project_path => File.dirname(File.dirname(file)),
            :sass_dir => File.basename(File.dirname(file)),
            :css_path => File.basename(File.dirname(file)),
            :output_style => :compressed
        },
        'alwaysmin' # A name for the configuration, can be anything you want
    )
    Compass.compiler.compile(File.dirname(file) + "/" + File.basename(file, '.css') + '.scss', File.dirname(file) + "/" + File.basename(file, '.css') + ".min.css")

  end

end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!