I wish to precompile all the CSS and JS files in my project\'s app/assets
folder. I do NOT want to precompile everything in vendor/assets or lib/assets, only th
I wanted all assets from both /app and /vendor to be compiled, except partials (which name starts from underscore _). So here is my version of an entry in application.rb:
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
vendor_assets_path = Rails.root.join('vendor', 'assets').to_path
if ((full_path.starts_with? app_assets_path) || (full_path.starts_with? vendor_assets_path)) && (!path.starts_with? '_')
puts "\t" + full_path.slice(Rails.root.to_path.size..-1)
true
else
false
end
else
false
end
}
Additionally it outputs list of files being compiled for debugging purposes...