使用ANT:
>下载JRuby完整的jar文件(JRuby Complete jar download page)
>下载最新的HAML / SASS代码(HAML/SASS tarball),并解压缩。把它放在“/ libs / sass- [VERSION]”
>将以下内容添加到ant构建文件。
>将脚本中的[VERSION]替换为相应版本的JRuby和SASS
>运行ant脚本,并编译sass或scss文件!
require 'libs/sass-[VERSION]/lib/sass'
require 'sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))
files.each do
| file |
puts " [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])
opts.parse
end
]]>
使用MAVEN:
Maven也可以这样做:
使用antrun插件:
org.apache.maven.plugins
maven-antrun-plugin
1.6
compileAndMinify
compile
run
require 'libs/sass-[VERSION]/lib/sass'
require 'sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))
files.each do
| file |
puts " [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])
opts.parse
end
]]>