Vite build not resolved css ulr()

Just starting with vite and faced problem after build project. During development everything was ok but after deploying on GH I realized that my background is missing images. All my images used in HTML are visible beside background images from CSS. Any reason why is that? https://github.com/solracss/fem-social-proof-section
GitHub
GitHub - solracss/fem-social-proof-section
Contribute to solracss/fem-social-proof-section development by creating an account on GitHub.
11 Replies
Jochem
Jochem•16mo ago
if you look in the console, you can see two 404 errors:
No description
C4rlos
C4rlosOP•16mo ago
i know but as total newbie with vite i dont know how to solve this 😦
Jochem
Jochem•16mo ago
I'm guessing you're using relative paths instead of full URLs and they start with a /, but your site is hosted at /fem-social-proof-section/. If a relative URL starts with /, it will assume it's referencing the root level of the domain
C4rlos
C4rlosOP•16mo ago
should i copy this to assets? You'r right
@include pseudo {
background: url("../../img/bg-pattern-top-mobile.svg") no-repeat;
}
@include pseudo {
background: url("../../img/bg-pattern-top-mobile.svg") no-repeat;
}
C4rlos
C4rlosOP•16mo ago
No description
Jochem
Jochem•16mo ago
yeah, you need to copy that to assets in your build step, and also adjust the reference so that it's accurate to where it ends up when deployed
C4rlos
C4rlosOP•16mo ago
move them to new /public ? vite should then copy
Jochem
Jochem•16mo ago
cause right now, https://solracss.github.io/fem-social-proof-section/bg-pattern-top-desktop.svg and https://solracss.github.io/fem-social-proof-section/img/bg-pattern-top-desktop.svg both 404 as well, so I don't think the image is available online in the deployment probably, yeah. I'm not super familiar with vite beyond using it in frameworks which set it all up for me
C4rlos
C4rlosOP•16mo ago
🙂 Moving to public and changing img paths to /img/... helped
Jochem
Jochem•16mo ago
nice!
xel
xel•16mo ago
sounds like you solved it but this is the documentation for that https://vitejs.dev/guide/assets.html
Vite
Next Generation Frontend Tooling
Want results from more Discord servers?
Add your server