Ruby on Rails Sunday, December 22, 2019



On Sunday, December 22, 2019 at 6:05:15 PM UTC-5, Ariel Juodziukynas wrote:
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 (<fuge...@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 rubyonra...@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.

I saw one post where someone suggests renaming javascripts to "webpacker" and then creating javascripts and images folders under "webpacker" Wanna get a good handle on being able to put assets wherever I want

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bd10518a-c532-42d0-ae2d-59818ea12874%40googlegroups.com.

No comments:

Post a Comment