Asset pipeline bug - rake assets:precompile doesn't add digest to images within css #9879

Closed
thelucid opened this Issue Mar 23, 2013 · 7 comments

Projects

None yet

4 participants

@thelucid
Contributor

I am trying to run a Rails 4 beta app in production and with the default production config, after running rake assets:precompile, all outputted files have digests on the end but the filenames within the .css.scss file to not include the digests meaning that the files come up as missing in the browser.

To replicate, create a brand new Rails 4 app (rails new asset_bug), add an application.css.scss file with the following content:

body { background: image-url('rails.png'); } 

Now run:

rake assets:precompile

The resulting application-?????.css file contains:

body { background: url(/assets/rails.png); } 

...but should contain:

body { background: url(/assets/rails-?????.png); } 

Any workarounds would be greatly appreciated as I have a client waiting to see a project I've been working on.

@guilleiguaran
Member

can you try with RAILS_ENV?:

RAILS_ENV=production rake assets:precompile

@thelucid
Contributor

I could kiss you Guillermo!! ...works a charm. I assumed this would be the default behaviour, I'm pretty sure it was in 3.2.

@rafaelfranca
Member

I think it should be the default

@guilleiguaran
Member

In 3-2-stable we are doing a hack to get this right:

https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/sprockets/assets.rake#L4-L25

Probably it isn't being done anymore because that code has been a pain to maintain since ever and the most common deployment scenarios (Capistrano and Heroku) are passing RAILS_ENV anyway.

@rafaelfranca
Member

Gotcha. So I think we can close this issue.

@thelucid
Contributor

Fair enough.

@etozzato

If anyone - like me - is still having issues:

gem 'rails', '4.0.0.rc2'
gem 'sass-rails', '~> 4.0.0.rc2'

fixed it :) 👍

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