Vue asset images not loading
See original GitHub issue- Laravel Mix Version: 6.0.9
- Node Version: 15.5.1
- NPM Version: 7.3.0
- OS: Mac OS Big Sur 11.1
Description:
After upgrading to Laravel Mix 6 my build runs successfully but images referenced from the assets folder no longer are loading.
Steps To Reproduce:
Running an existing Laravel v8.21.0 project with Laravel/UI Vue auth scaffolding, after upgrading Laravel Mix to version 6 images referenced from the assets folder in Vue don’t err out on build but display as broken images in the browser.
Referencing images as such:
<img src="../assets/logo.png" alt="Logo">
When I inspect the image I see this:
<img src="[object Module]" alt="Logo">
Any help would be greatly appreciated. Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:16
Top Results From Across the Web
vue assets image not load - Stack Overflow
First you have to bind your image path to the src property and then you have to wrap the path in require('@/assets/profile.jpg') to...
Read more >Adding static images to a component, they do not appear
Files in the assets folder are not copied across to the build output directly. They undergo tree-shaking so you need an import or...
Read more >Image asset within component not displaying - Laracasts
Image asset within component not displaying. I have a component.vue file that looks like such: Copy Code <div class="category-container__item-row" ...
Read more >Error loading image - Material Design for Bootstrap
The image I'm trying to load is in the assets folder and the vue file is in the components folder. The error is...
Read more >Images, fonts, and assets - Storybook - JS.ORG
In this case, you need to have all your images and media files with relative paths. Otherwise, the browser cannot locate those files....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apparently its a bug with vue-loader which Mix uses. Here is my workaround solution. This only sets esModule to false on the images file-loader.
@Aiwings Thanks for the response.
I was also able to get the image loaded by doing this:
Both of these solutions feel kinda ugly to me tbh.