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.

Yea I know but I already see people saying why use both Also I wanna get used to this This is the first technology I'm getting in on the ground floor I feel, the time to learn/get used to using webpacker is now Moving all assets to webpacker is good practice for me Also using webpack-dev-server is a step forward, as soon as you save a file it recompiles and you get rewarded for doing something right when you save the file and the screen lights up green like a pinball machine rewards you for scoring

--
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/8fe59f11-ae63-4533-80bd-8334cce04738%40googlegroups.com.

No comments:

Post a Comment