Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Precompile assets locally but keep the manifest files in source control

This setup will allow you to precompile assets locally and keep them separated depending on the environment. To precompile assets locally run RAILS_ENV=production COMPILE_ASSETS=1 rake assets:precompile. Using an ENV var like this removes the need for having therubyracer or some other javascript engine on your server instances since they aren't actually running the precompilation task.

public/assets*/*
!public/assets*/manifest*.json
!public/assets*/manifest*.yml
# Set a different path for non-production assets
config.assets.prefix = "/assets_#{Rails.env}" unless Rails.env.production?
if ENV['COMPILE_ASSETS']
# If Rails 3, use:
config.assets.compress = true
# If Rails 4, use:
config.assets.js_compressor = :uglify
config.assets.css_compressor = :sass
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.