Per-server conditional asset precompilation #174

wants to merge 3 commits into


None yet
7 participants

2-718 commented Mar 3, 2012

This pull request implements conditional asset precompilation on a per-server basis (the check is conducted server-side to properly allow parallel deployment). I added String#unindent to facilitate heredoc whitespace cleanup.

pyrat commented Mar 27, 2012

+1 for this, as asset precompilation takes at least 30 seconds, this is a pain unless needed. Having this baked into capistrano would be a big help.

antage commented Apr 17, 2012

If I update jquery-rails gem (for example) to a new version, capistrano with this patch doesn't recompile assets.
I suggest to check Gemfile.lock. Any changes in Gemfile.lock should trigger assets rebuilding.


cgriego commented Jun 1, 2012

Could this instead be implemented as a Rails plugin that overloads the asset compilation Rake task? Seems useful outside the context of just Capistrano deployments, works with existing infrastructure, and then you have the power of Ruby and not just bash and have a shot of detecting gem changes.


jrochkind commented Sep 28, 2012

Yeah, the problem with just doing a diff of ./{app|vendor|lib}/assets is that assets can come from gems too. For instance, jquery-rails. One can imagine complicated workarounds, involving gem dependency changes (but if any gem dependency change triggers asset precompile.... you will be avoiding compile infrequently). Or a hook into rails that checks all the source asset_paths, yeah.

I think the different approach, within Rails, being taken by @ndbroadbent in rails/sprockets-rails#21 is probably the more realistic solution, esp since @ndbroadbent has actually done the work. If anyone has the time to spend on it, it would probably be a good use of that time to help them get that patch into rails, by testing etc.


ndbroadbent commented Oct 1, 2012

Hey @jrochkind, thanks for the mention!
I'd also like to point out that I've released this as a gem for Rails 3, called turbo-sprockets-rails3. It overrides sprockets so that only changed assets are precompiled, and nondigest assets are quickly generated from the precompiled assets (so you only need to compile assets once, instead of twice.)
You can use it in your Rails 3.2.x application by adding gem 'turbo-sprockets-rails3' to your Gemfile, and I'd really appreciate it if you could help me test it out. Please open an issue if you run into any problems.



carsomyr commented Oct 2, 2012

I'm closing this PR and directing further discussion to issue #227.

@carsomyr carsomyr closed this Oct 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment