Search code examples
ruby-on-rails-3.1asset-pipeline

rake assets:precompile is slow


The command "rake assets:precompile" works very slow for me. Especially on my Amazon EC2 Micro production server which does not have a lot of processor resources. On EC2 I have to wait 1 minute or more during each deployment just for this precompile task alone. Is there a way to make it faster?

Previously I used Jammit to compress/minify css and js. Jammit worked nearly 10 times faster on the same web site and servers.


Solution

  • If you don't need to load the Rails environment, you should disable that with:

    config.assets.initialize_on_precompile = false
    

    EDIT: I've just written a gem to solve this problem, called turbo-sprockets-rails3. It speeds up your assets:precompile by only recompiling changed files, and only compiling once to generate all assets.

    It would be awesome if you could help me test out the turbo-sprockets-rails3 gem, and let me know if you have any problems.