1 | initial version |
To access an image in an SCSS file on an app that is using Vite_Rails, you can use the following steps:
Make sure your image is in the app/assets/images
directory.
In your SCSS file, use the url
function to reference the image like this:
background-image: url('/assets/images/your-image.png');
Note that the path should start with /assets
.
In your application.scss
file, make sure to import your SCSS file:
@import 'your-file';
In your HTML file, make sure to include the following tag:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
This tag will load the CSS file and make sure that your image is displayed correctly.
Finally, run your app with the rails server
command and access your page to see the result.