3

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.

Undistraction
  • 42,754
  • 56
  • 195
  • 331
  • Any update on that? Do you know why the slug size remains above limit while deploying to Heroku? – p.matsinopoulos Sep 09 '15 at 16:04
  • 1
    @p.matsinopoulos I stopped using Asset Sync a long time back. I think I wasted more hours on issues involving it than all other Gems combined. I now use the (far preferable) approach of pushing everything to Heroku and using a CDN in front. With an S3 bucket fronted by a different CDN for dynamically generated assets. – Undistraction Sep 23 '15 at 17:15

1 Answers1

3

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.

p.matsinopoulos
  • 7,655
  • 6
  • 44
  • 92
Schneems
  • 14,918
  • 9
  • 57
  • 84