ruby-on-railssprocketsruby-on-rails-7dart-sasspropshaft

Background image not compiling into assets folder using propshaft with dartsass-rails in rails 7


Using Rails 7 with Propshaft and dartsass-rails. I've just migrated from sassc-rails to dartsass-rails which drops sprockets as the asset pipeline library

I have a background image declared in CSS with background-image: image-url('fancy_background.png'); the image is in app/assets/images/fancy_background.png

The image is not showing up in the assets folder. Other images which are declared in the HTML do get pulled in. How should I be referencing images in CSS with the "new" way?


Solution

  • The issue here was migrating from sprockets to propshaft.

    Background images now need to be referenced with just url EG:

    background-image: url('/fancy_background.png');
    

    Source: https://github.com/rails/propshaft/blob/main/UPGRADING.md#3-migrate-from-sprockets-to-propshaft