Skip to content

Instantly share code, notes, and snippets.

@novrian
Created September 11, 2013 15:15
Show Gist options
  • Save novrian/6525061 to your computer and use it in GitHub Desktop.
Save novrian/6525061 to your computer and use it in GitHub Desktop.
Put this on your config.rb to make compass generate sprite without hash.
# Thanks to piouPiouM
#
# @see http://stackoverflow.com/questions/9183133/how-to-turn-off-compass-sass-cache-busting/9332472#9332472
# @link http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html
# Make a copy of sprites with a name that has no uniqueness of the hash.
on_sprite_saved do |filename|
if File.exists?(filename)
FileUtils.cp filename, filename.gsub(%r{-s[a-z0-9]{10}\.png$}, '.png')
end
end
# Replace in stylesheets generated references to sprites
# by their counterparts without the hash uniqueness.
on_stylesheet_saved do |filename|
if File.exists?(filename)
css = File.read filename
File.open(filename, 'w+') do |f|
f << css.gsub(%r{-s[a-z0-9]{10}\.png}, '.png')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment