問題タブ [ruby-on-rails-6]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
css - Ruby on Rails 6 css のアセット パイプラインから画像を参照する方法
Rails 6 アプリケーションを作成しようとしています。Rails 5 では、sass がまだ適用可能でしたが、image-url(xxx.png) を使用してアセット パイプライン内の画像を参照していました。ただし、Rails 6 では、これは Web パックには適用されなくなりました。画像を読み込めないようです。
asset-url などのさまざまなタグを使用して、直接パスの URL を調整しようとしましたが、うまくいきませんでした。
.banner { background-image: url(asset_path('home/head-banner.png')); ... }
.banner { background-image: image-url('home/head-banner.png'); ... }
期待される結果は、画像の完全にハッシュ化された URL です。