Images with vite #41205
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
It sounds like the issue might be related to how Vite processes and serves assets compared to using Bootstrap via a link. When using Vite, the way static assets like images are handled might differ, and it's possible that Vite's dev server is either not serving the images correctly or they're being incorrectly referenced. Bootstrap itself won't affect image visibility by default, nor does it alter how images should be displayed. The issue seems to be more about how Vite handles your asset paths and MIME types. |
Beta Was this translation helpful? Give feedback.
-
As Julien mentioned, the issue is more likely related to your paths config for Vite. I encountered similar issues before and the core problem was in the configuration of the base url in the vite.config file, its relation to your assets location and how you import them in your components. In addition, Vite does not resolve CSS paths by default. You might need to set up a custom resolve that might look like the following: import path from 'path';
export default defineConfig({
// ... the rest of your configuration
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
}); In CSS, paths would look like the following: background: url(@/assets/icons/icon-time.svg) no-repeat; So:
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! I've just found this solution; I just didn't put the public file in the src file, all of this because of that. |
Beta Was this translation helpful? Give feedback.
It sounds like the issue might be related to how Vite processes and serves assets compared to using Bootstrap via a link. When using Vite, the way static assets like images are handled might differ, and it's possible that Vite's dev server is either not serving the images correctly or they're being incorrectly referenced. Bootstrap itself won't affect image visibility by default, nor does it alter how images should be displayed. The issue seems to be more about how Vite handles your asset paths and MIME types.