I have a large rails app with hundreds of coffee script files.
Sometimes when I make a tiny change in a coffeescript file or I switch the branch the whole assets are being precompiled and I have to wait a long time for load the page:
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-11 19:39:45 +0100
Compiled sprockets/commonjs.js (0ms) (pid 18142)
Compiled jquery.js (2ms) (pid 18142)
Compiled jquery_ujs.js (0ms) (pid 18142)
Compiled underscore.js (0ms) (pid 18142)
Compiled backbone.js (0ms) (pid 18142)
Compiled backbone_rails_sync.js (0ms) (pid 18142)
Compiled handlebars.runtime.js (0ms) (pid 18142)
Compiled moment.js (0ms) (pid 18142)
...and so on
I use the following assets configuration config/development.rb
:
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = false
When I set config.assets.debug = false
I have to wait quite long time for load hundreds of js files.
The question is: how to find the golden mean? How to optimize assets configuration in the development mode for the large app?
Take a look at this middleware from the Discourse team. We've had great success with it in our rails 4 app -- took reload times down from a minute to 5 seconds in development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With