How to combine compass with bless?

喜你入骨 提交于 2019-12-01 17:06:56

Well, it seems that using this reference you can simply do something like:

on_stylesheet_saved do |filename|
    system('blessc ' + File.basename(filename))
end

after you have installed Bless.

What it does is simply attaching that event after you compile your Compass file :) Enjoy

This works for the regular compile command, but it doesn't work when you watch it. After Bless is completed the watch process ends.

I found that blessc just wouldn't execute, I'd get one of these two errors:

config.rb: No such file or directory - blessc (whatever filename)

or

env: node: No such file or directory

It turns out this is because blessc/node.js are installed in /usr/local/bin, and that is not in the PATH variable for ruby exec (/usr/bin:/bin:/usr/sbin:/sbin). The following code worked:

on_stylesheet_saved do |filename|
  exec('PATH=$PATH:/usr/local/bin; blessc ' + filename + ' -f')
end

Edited to add: If after this you get errors saying that the files aren't css from bless, check if your absolute path to the file contains white space. You can escape the white space by doing the following:

on_stylesheet_saved do |filename|
  exec('PATH=$PATH:/usr/local/bin; blessc ' + (filename.gsub! ' ', '\ ') + ' -f')
end
Aritrik

You can try the following code block, I've made couple of changes of Julian Xhokaxhiu answer:

on_stylesheet_saved do |filename|
  begin
    puts "Counting number of selector in :: " + filename
    result = system('blessc',filename,'-f')

    if not result
      Kernel.exit(false)
    else
      puts "Blessed the file to support Older version of IE."
    end

  rescue Exception => e
    puts "Please install bless.\nsudo npm install -g bless."
    Kernel.exit(false)
  end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!