Created
May 15, 2012 22:49
-
-
Save jmccartie/2705745 to your computer and use it in GitHub Desktop.
Convert all your css files to sass
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
require 'rubygems' | |
require 'sass/css' | |
Dir["/PATH/TO/YOUR/PROJECT/app/assets/stylesheets/**/*.css"].each do |file| | |
puts "==> Starting #{file}..." | |
# file properties | |
basename = File.basename(file, ".css") | |
dir = File.dirname(file) | |
# convert to new file | |
old_data = IO.read(file) | |
new_data = Sass::CSS.new(old_data).render(:sass) | |
# save to file.sass | |
File.open("#{dir}/#{basename}.sass", 'w') {|f| f.write(new_data) } | |
# remove file.css | |
File.delete(file) | |
puts "\n==> Completed converting #{file}.\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want Scss, just change line 14 from ":sass" to ":scss"