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

huangapple go评论63阅读模式
英文:

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

问题

在使用Rails 7与Propshaftdartsass-rails时,我刚从sassc-rails迁移到dartsass-rails,它将sprockets作为资源管道库移除了。

我在CSS中声明了一个背景图像,代码如下:background-image: image-url('fancy_background.png');,该图像位于app/assets/images/fancy_background.png目录下。

这个图像在资源文件夹中没有显示出来。其他在HTML中声明的图像可以正常加载。请问在CSS中如何以“新”的方式引用图像?

英文:

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?

答案1

得分: 0

这里的问题是从 sprockets 迁移到 propshaft。

现在需要仅使用 url 引用背景图像,例如:

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

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

英文:

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

huangapple
  • 本文由 发表于 2023年6月8日 16:09:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76429853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定