for example, in rails application have like:
.wax_seal { background: url("wax-seal-small.png"); display: block; height: 100px; margin: 0 auto; width: 92px; } .wax_seal:active { background: url('wax-seal-small-broken.png'); }
and in config/environments/production.rb
file:
# disable rails's static asset server (apache or nginx this). config.serve_static_assets = true
i manually invoke compiling of assets:
bundle exec rake assets:precompile
and files created hashes @ end of name:
wax-seal-small-uuhqwduhqwdoi234983jewf.png
so doesn't work:
background: url("wax-seal-small.png");
but works fine (when manually type in chrome):
background: url("wax-seal-small-uuhqwduhqwdoi234983jewf.png");
what step missing here? how can make css rules add in little hash?
adding config.assets.compile = true
in config/environments/production.rb
makes work, read in rails guide it's bad practice due significant performance hits.
i found in edgerails documentation: http://edgeguides.rubyonrails.org/asset_pipeline.html#css-and-sass
2.3.2 css , sass
when using asset pipeline, paths assets must re-written , sass-rails provides -url , -path helpers (hyphenated in sass, underscored in ruby) following asset classes: image, font, video, audio, javascript , stylesheet.
image-url("rails.png") becomes url(/assets/rails.png)
image-path("rails.png") becomes "/assets/rails.png"
the more generic form can used asset path , class must both specified:
asset-url("rails.png", image) becomes url(/assets/rails.png)
asset-path("rails.png", image) becomes "/assets/rails.png"
Comments
Post a Comment