Skip to content

Instantly share code, notes, and snippets.

@LeonFedotov
Created November 15, 2012 14:35
Show Gist options
  • Save LeonFedotov/4078922 to your computer and use it in GitHub Desktop.
Save LeonFedotov/4078922 to your computer and use it in GitHub Desktop.
coffee-script with sourcemaps
COFFEE_EXEC = '/Users/leon/code/resources/CoffeeScriptRedux/bin/coffee' #https://github.com/michaelficarra/CoffeeScriptRedux/
def create_js(source)
target = "#{File.dirname(source)}/js/#{File.basename(source, '.coffee')}.js"
puts "#{COFFEE_EXEC} --js -i #{source} > #{target}"
%x{#{COFFEE_EXEC} --js -i #{source} > #{target}}
puts "#{COFFEE_EXEC} --source-map -i #{source} > #{target}.map"
%x{#{COFFEE_EXEC} --source-map -i #{source} > #{target}.map}
puts "(echo; echo '//@ sourceMappingURL=#{target}.map') >> #{target}"
%x{(echo; echo '//@ sourceMappingURL=#{target}.map') >> #{target}}
end
Dir.foreach(Dir.pwd) do |file|
create_js(file) if File.extname(file) == '.coffee'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment