-
-
Save nissuk/1358544 to your computer and use it in GitHub Desktop.
HAML, SCSS, CoffeeScriptの自動コンパイル実験(watchr)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on http://www.223soft.net/35 | |
class W | |
def initialize(opts) | |
@dest_dir = opts[:dest_dir] | |
end | |
def exec(cmd, md) | |
p = Pathname.new(@dest_dir + "/" + File.dirname(md[0])) | |
p.mkdir if not p.exist? | |
puts "compiled to #{md[0]}" if system(cmd) | |
end | |
end | |
dest_dir = "dest" | |
w = W.new(:dest_dir => dest_dir) | |
watch("(.*)\.haml") {|md| | |
w.exec("haml -f html5 #{md[0]} -E UTF-8 #{dest_dir}/#{md[1]}.html", md) | |
} | |
watch("(.*)\.scss") {|md| | |
w.exec("sass --scss #{md[0]} #{dest_dir}/#{md[1]}.css", md) | |
} | |
watch("(.*)\.coffee") {|md| | |
w.exec("coffee -o #{dest_dir} -c #{md[0]}", md) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment