Question

I have a Rails 3.2 app that has a lot of assets. That's OK because I'm using the [Asset Sync Gem(https://github.com/rumblelabs/asset_sync) which pushes all my compiled assets to an S3 bucket.

Problem is that these assets are still included in the slug size even though the application uses the versions on S3. This is causing my slug size to end up going over the 300MB limit.

I can't use a .slugignore file as this would prevent the files from being synced, so how can I delete all the assets once AssetSync has pushed them to S3 and before the slug is compiled?

[UPDATE]

I now precompile everything locally. Heroku is super-slow at compiling assets and more importantly, it compiles everything every time. Once your assets reach a non trivial size, this is really painful. I now precompile locally and have a Rake task that checks in the manifest and pushes to Heroku.

Was it helpful?

Solution

You can add behavior that deletes the directory after assets:clean is run

require 'fileutils'
Rake::Task["assets:clean"].enhance do
  FileUtils.remove_dir "#{Rails.root}/public/assets", true
end

You can put that in your Rakefile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top