Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compass config.rb
# Note that while this file is in our config folder, it is
# symlinked to our site folders, so paths are relative from there
# Require gems and Compass plugins
# require 'rgbapng'
# require 'compass-fancybox-plugin'
require 'compass-growl'
# General
output_style = :expanded
relative_assets = true
project_path = File.dirname(__FILE__) + '/'
env_file = project_path + 'environment.rb'
add_import_path project_path + '../all/public/assets/styles/src/'
lib_dir = project_path + '../../system/lib/'
# Sass Paths
http_path = '/'
http_javascripts_path = http_path + 'assets/scripts/'
http_stylesheets_path = http_path + 'assets/styles/'
http_images_path = http_stylesheets_path + 'images/'
http_fonts_path = http_stylesheets_path + 'fonts/'
# Sass Directories
javascripts_dir = 'public/assets/scripts/'
css_dir = 'public/assets/styles/'
sass_dir = css_dir + 'src/'
images_dir = css_dir + 'images/'
fonts_dir = css_dir + 'fonts/'
# Quantize 8-bit sprites
on_sprite_saved do |file|
unless is_32bit?(file)
quantize(file, lib_dir + 'pngquant/pngquant-mac')
end
optimize(file, 'ImageOptim')
end
# Enable Debugging (Line Comments, FireSass)
# Invoke from command line: compass watch -e development --force
if environment == :development
line_comments = true
sass_options = { :debug_info => true }
end
# Optionally load environmental overrides
if File.exists?(env_file)
require env_file
end
# Methods
def is_32bit?(file)
File.basename(file).match(/^png(24|32)/)
end
def quantize(file, binary)
png8_file = file.sub(/\.png/, '-fs8.png')
system binary + ' ' + file
sleep 2
system 'mv -f ' + png8_file + ' ' + file
growl('Sprite: ' + File.basename(file) + ' quantized')
end
def optimize(file, image_app)
system 'open -a ' + image_app + '.app ' + file
growl('Sprite: ' + File.basename(file) + ' optimized')
end
def growl(msg)
GNTP.notify({
:title => "Compass",
:text => msg,
:icon => "file://#{CompassGrowl::ICON}"
})
end
@timkelty
Copy link
Author

timkelty commented Jan 11, 2012

http://www.viget.com/inspire/stop-making-sprites-compass-sass-and-png-sprite-generation/
Disqus was broken, so I'm putting here.

I started with your config.rb and tweaked it a bit. Using your code, it wasn't excluding 24bit dirs, because filename is the whole path, not just the filename (maybe something in Compass changed?).

Anyway, I fixed that, and also updated the Growl call to work with the official compass-growl gem: https://github.com/Compass/compass-growl

Enjoy, and thanks!

@averyvery
Copy link

averyvery commented Jan 11, 2012

Thanks, Tim! I could be missing something, but what's the point of compass-growl? Does it do something that another ruby Growl library wouldn't?

@timkelty
Copy link
Author

timkelty commented Jan 11, 2012

Well, compass-growl out of the box will Growl for init, stylesheet saved, error, sprite generated, just by requiring it in your config.rb.
Since I'm already using that I figured I would use the same growl lib they are (GNTP) to Growl the quantize message. That way I can steal their icon too :). Other than that, theres no reason you couldn't use another one.

@averyvery
Copy link

averyvery commented Jan 11, 2012

Well, that sounds awesome. Will have to add this to my compass.rb, too.

@hitmands
Copy link

hitmands commented Nov 2, 2013

i'm trying to use sass media query combiner ( https://github.com/aaronjensen/sass-media_query_combiner ) with my compass project, can anyone help me?
I use
sass 3.2
compass 0.12

and compile my scss with compass (ex: compass watch)
Thanks

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