Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Forked from chriseppstein/readme.md
Created September 16, 2011 18:16
Show Gist options
  • Save thenoseman/1222733 to your computer and use it in GitHub Desktop.
Save thenoseman/1222733 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

Installing Compass Plugins

  1. Gem based plugins: Add plugin to Gemfile

  2. Archive based plugins: unpack the extension into vendor/plugins/compass_extensions

  3. (optionally) Install the plugin templates. E.g.

    bundle exec compass install <plugin>
    
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'
# include other compass plugins here. E.g.:
gem 'compass-susy-plugin', :require => 'susy'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment