Skip to content

Instantly share code, notes, and snippets.

@shamrt
Created July 11, 2013 19:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shamrt/5978457 to your computer and use it in GitHub Desktop.
Save shamrt/5978457 to your computer and use it in GitHub Desktop.
Padrino application setup with Compass
module Profile
class App < Padrino::Application
set :root, File.dirname(__FILE__) # Must be set
register Padrino::Rendering
register Padrino::Helpers
enable :sessions
##
# Assets management
# Compass
register Sinatra::CompassSupport
sass_dir = File.join(File.dirname(__FILE__), 'assets/scss')
Compass.configuration do |c|
c.project_path = root
c.images_dir = "assets/images"
c.http_generated_images_path = "/images" # necessary for sprite generation
c.http_images_path = "/images"
c.cache_dir = '../tmp/sass-cache' # optional
c.sass_options = {
load_paths: [sass_dir] + Compass.sass_engine_options[:load_paths] } # necessary if using SASS partials
end
# Asset Pack
register Sinatra::AssetPack
set :scss, Compass.sass_engine_options # necessary if using SASS partials
assets {
serve '/js', from: 'assets/javascripts'
serve '/css', from: 'assets/scss'
serve '/images', from: 'assets/images'
js :app, [
'/js/jquery.js',
'/js/jquery-ujs.js',
'/js/app.js'
]
css :styles, ['/css/styles.css']
css :ie, ['/css/ie.css']
js_compression :uglify
css_compression :sass
}
end
end

Structure of key application directories

  • padrino_app
    • app
      • assets
        • images
        • javascripts
        • scss
      • app.rb
## Add to your Padrino Gemfile…
# Assets
gem 'sass'
gem 'uglifier'
gem 'sinatra-assetpack'
gem 'sinatra-support', :require => 'sinatra/support/compasssupport'
# Component requirements
gem 'haml'
gem 'compass'
@cedricraud
Copy link

Oh god, you saved my day. Much <3

@ottodranik
Copy link

It's cool! Thx!

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