Skip to content

Instantly share code, notes, and snippets.

@grafikchaos
Created June 8, 2012 02:12
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 grafikchaos/2893057 to your computer and use it in GitHub Desktop.
Save grafikchaos/2893057 to your computer and use it in GitHub Desktop.
precompile all CSS/JS assets
# == Precompile assets
#
# precompiles all CSS/JS assets in the app/assets b/c I'm lazy
# and I don't want to freaking update this every time we add/use
# sass or coffeescript files
#
# This strategy excludes the other default asset directories
# (lib/assets, vendor/assets) as well as any assets located
# in gems (which is okay b/c they can be called with an @import
# command or a manifest file)
#
# see http://stackoverflow.com/a/10110226
config.assets.precompile << Proc.new { |path|
if path =~ /\.(css|js)\z/
full_path = Rails.application.assets.resolve(path).to_path
app_assets_path = Rails.root.join('app', 'assets').to_path
if full_path.starts_with? app_assets_path
puts "including asset: " + full_path
true
else
puts "excluding asset: " + full_path
false
end
else
false
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment