Question

Precompiling assets on the production server is very slow. So I have decided to recompile them on the development machine and upload assets to the Amazon S3 by jammit. Everything's done but I have some negative problems:

  1. I have to include public/assets directory to git control. Because if public/assets directory is empty on the production server fails
  2. If I precompile assets on the development machine application.js includes in the HTML as compressed and that way I have duplicated js code. Changing js doesn't make any effect because precompiled application.js interrupts this code.

That way my development process includes following steps:

  1. Remove precompiled assets if I'm going to change js or css
  2. Do some changes
  3. Precompile assets
  4. Upload assets to S3 by jammit-s3
  5. Do commit and push my changes including assets to the git server
  6. Deploy by capistrano

My questions are:

  1. Is it possible to configure development environment don't include compressed application.js if I have it in public/assets directory?
  2. Is it possible to configure production environment to work with empty public/assets directory? Assets will only be on the S3 server.
Was it helpful?

Solution 2

I resolved this problem by including assets dir in gitignore and exclude only one file - public/assets/manifest.yml and production server works correctly now, i.e. config.action_controller.asset_host = "http://assets.example.com" works. It requires only manifest.yml file

OTHER TIPS

For question one I don't know a permanent solution other than running:

bundle exec rake assets:clean

before you switch back to development mode. I'd be interested to see if you can just ignore the assets in development without turning the entire assets pipeline off.

In production.rb there is an option for your second question:

# Enable serving of images, stylesheets, and JavaScripts from an asset server
config.action_controller.asset_host = "http://assets.example.com"

It should then ignore your assets directory since it relies on the remote host. Hope that helps.

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