Posted almost 11 years ago. Visible to the public.

Automatically build sprites with Lemonade

How it works

See the lemonade descriptions.

Unfortunately, the gem has a few problems:

  • it does not work with Sass2
  • it always generates all sprites when the sass file changes, which is too slow for big projects
  • it expects a folder structure quite different to our usual

All these problems are solved for us, in our own lemonade fork. This fork has since been merged to the original gem, maybe we can use that one now too.


  • gem install compass -v=0.10.2

  • gem install chunky_png -v=0.8.0

  • freeze our lemonade version

    • cd vendor/gems
    • git clone lemonade-0.3.4
    • rm -rf lemonade-0.3.4/.git
  • in config/environment.rb:

    • config.gem 'compass', :version => '=0.10.2'
    • config.gem 'lemonade', :version => '=0.3.4'
    • config.gem 'chunky_png', :version => '=0.8.0'
  • create config/initializers/compass.rb (or copy from development repo):
    require 'compass'
    rails_root = (defined?(Rails) ? Rails.root : RAILS_ROOT).to_s
    Compass.add_project_configuration(File.join(rails_root, "config", "compass.rb"))

  • create config/compass.rb (or copy from development repo):

    This configuration file works with both the Compass command line tool and within Rails.

    Require any additional compass plugins here.

    project_type = :rails
    project_path = Compass::AppIntegration::Rails.root

    Set this to the root of your project when deployed:

    http_path = "/"`
    css_dir = "public/stylesheets"
    sass_dir = "public/stylesheets/sass"
    images_dir = "public/images"
    http_images_path = "../images"
    environment = Compass::AppIntegration::Rails.env

    To enable relative paths to assets via compass helper functions. Uncomment:

    relative_assets = true

    require 'lemonade'

  • in .gitignore:


This setup is still not optimal:

  • dependency on compass is unnecessary
  • installation a bit involved (maybe we can use the usual gem?)
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Tobias Kraze
Last edit:
over 10 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more