Skip to content

Instantly share code, notes, and snippets.

@darren131
Created May 9, 2014 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darren131/aa61bbc4fa5e177eb437 to your computer and use it in GitHub Desktop.
Save darren131/aa61bbc4fa5e177eb437 to your computer and use it in GitHub Desktop.
Default compass config file
require 'autoprefixer-rails'
require 'breakpoint'
require 'scut'
require 'sass-media_query_combiner'
http_path = "/"
sass_dir = "sass"
css_dir = "public/css"
http_stylesheets_path = "/css"
images_dir = "public/images"
http_images_path = "/images"
http_generated_images_path = "/images"
javascripts_dir = "public/js"
http_javascripts_path = "/js"
fonts_dir = "public/fonts"
http_fonts_path = "/fonts"
output_style = (environment == :production) ? :compressed : :expanded # for live: compass compile -e production --force
color_output = false
# -------------------- Autoprefix
on_stylesheet_saved do |file|
css = File.read(file)
File.open(file, 'w') do |io|
io << AutoprefixerRails.process(css)
end
end
# -------------------- Compress sprites
# callback - on_sprite_saved
# http://compass-style.org/help/tutorials/configuration-reference/
on_sprite_saved do |filename|
if File.exists?(filename)
# if (environment == :production)
# Post process sprite image
postprocesspng(filename)
# end
end
end
# fn - Post processing for pngs
# http://compass-style.org/help/tutorials/configuration-reference/
# http://pngquant.org/
# http://advsys.net/ken/utils.htm & http://nicj.net/2012/05/15/pngoutbatch
# http://optipng.sourceforge.net/
def postprocesspng(filename)
print "**********************\r\n"
print "Compressing sprites...\r\n"
print "**********************\r\n"
if File.exists?(filename)
sleep 1
optimize(filename, "pngquant --iebug --force --ext .png 256")
optimize(filename, "pngout -c3 -b0 -v")
optimize(filename, "optipng -o7 -verbose")
end
end
# fn - Run optimize command line for a specified script
# https://gist.github.com/2403117
def optimize(filename, script)
if File.exists?(filename)
sleep 1
print "\r\n** Running: " + script + " " + Shellwords.escape(filename) + "\r\n\r\n"
system script + " " + Shellwords.escape(filename)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment