Skip to content

Instantly share code, notes, and snippets.

@jmccartie
Created May 15, 2012 22:49
Show Gist options
  • Save jmccartie/2705745 to your computer and use it in GitHub Desktop.
Save jmccartie/2705745 to your computer and use it in GitHub Desktop.
Convert all your css files to sass
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
@jmccartie
Copy link
Author

If you want Scss, just change line 14 from ":sass" to ":scss"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment