Webpacker provides an `asset_pack_path` method
https://github.com/rails/webpacker#usage

I guess you'll need to use a .css.erb file in order for that to work.

# something.css.erb

.search_button {
  background: url('<%= asset_pack_path('images/search.png') %>');
}

Lately you are asking A LOT of questions about webpacker for images and
CSS, you don't really HAVE to change from Sprockets to Webpacker to update
to rails 6, in fact, if you start a new rails app, it uses webpacker only
for javascript assets, it's still using sprockets for css and images by
default. Of course you are free to use webpacker for everything but maybe
you have to follow webpack guidelines and start messing with loaders, check
the webpack guide on packing images and using it for background image for
example https://webpack.js.org/guides/asset-management/#loading-images

El dom., 22 dic. 2019 a las 17:12, fugee ohu (<fugee...@gmail.com>)
escribió:

> Webpacker is serving images in views, I just don't know how to do it in css
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/549cd10d-f440-4ca0-a3a5-51748c623e92%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcB9iMN5kwO%2B6VOoQoHuLDi90hzxC9xSt7RUxD45bUXQgA%40mail.gmail.com.

Reply via email to