'rails new cssbundling-rails gem issue with images on production
I'm testing the new rails cssbundling-rails gem. I'm following the default config, but on prod, I'm getting a 404 error with the images path in the .scss
files
Failed to load resource: the server responded with a status of 404 (Not Found)
In development, this works properly.
"scripts": {
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules",
"build": "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds"
}
in my application.bootstrap.scss
.table th .asc-arrow {
background-image: url(up_arrow.gif);
}
I checked and my image is in the public/assets folder, but for some reason it doesn't have the random hash in the name when I use the url(up_arrow.gif);
https://mywebsite.com/assets/up_arrow.gif not https://mywebsite.com/assets/up_arrow-08e7aace9abfe2ae82a1b5fb892863da155c5e30555cb8f3978ea0ccd698e5f9.gif
up_arrow-08e7aace9abfe2ae82a1b5fb892863da155c5e30555cb8f3978ea0ccd698e5f9.gif
Solution 1:[1]
This bug was fixed by https://github.com/rails/sprockets-rails/pull/476, but if still not working and you want to make it simpler, try to move up_arrow.gif
to rails public and will work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pedro Augusto Ramalho Duarte |