Skip to content

Instantly share code, notes, and snippets.

@laribee
Forked from chriseppstein/readme.md
Created December 28, 2011 03:46
Show Gist options
  • Save laribee/1526103 to your computer and use it in GitHub Desktop.
Save laribee/1526103 to your computer and use it in GitHub Desktop.
How to integrate Compass with Rails 3.1 asset pipeline

Compass is even easier to use in Rails 3.1

Compass Rails integration is trivial in rails 3.1. The "config/compass.rb" file is optional now.

During deploy run:

rake assets:precompile

Additional Upgrade instructions

  1. Move your stylesheets from app/stylesheets or public/stylesheets/sass to app/assets/stylesheets.
  2. Rename all non partials to *.css.s[ac]ss
if defined?(Bundler)
Bundler.require *Rails.groups(:assets => %w(development test))
end
stylesheets_directory = "#{Rails.root}/app/assets/stylesheets"
config.assets.precompile += Dir.glob("#{stylesheets_directory}/**/*.s[ac]ss*").
map{|f| f[stylesheets_directory.size+1..-1]}.
select do |file|
if config.assets.precompile.include?(file)
false
elsif File.basename(file)[0...1] == "_"
false
else
true
end
end
# if you prefer `.sass` over `.scss`.
config.sass.preferred_syntax = :sass
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass', '~> 0.12.alpha'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment