Skip to content

Instantly share code, notes, and snippets.

@swrobel
Last active August 29, 2015 13:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swrobel/8856129 to your computer and use it in GitHub Desktop.
Save swrobel/8856129 to your computer and use it in GitHub Desktop.
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