简体   繁体   中英

How do I speed up asset precompiling in Rails 3+?

Every time I pull code into my repository after making changes to JS or CSS files, I run the following commands:

rake assets:clean
rake assets:precompile

I've got quite a bit of assets, so this process always takes at least a minute. Is there any way to get it to go faster? For example, if I've only changed CSS, is there a way to tell it to only focus on CSS files and not to bother cleaning and precompiling JS?

Edit: Oops, I should have specified that this is on production. I'm aware I don't need to precompile assets on development :)

I am assuming that you are running Rails >3.1.

Don't run the rake tasks at all. Rails development mode doesn't need the assets to be precompiled. Rails will automagically compile the assets when there is a change else it will not.

If you are looking for performance while serving assets in development you can look the gems such as https://github.com/wavii/rails-dev-tweaks

This an add-on not pretending to be an answer.

Process monitor in Windows shows that ruby.exe makes cycles while doing assets:precompile and in each cycle it queries all the gems installed again and again.

Rails 3.2.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM