#Images not bundling

4 messages · Page 1 of 1 (latest)

lost saddle
#

I am trying to load images dynamically from the /public folder, but when I build the apps it doesn't load the images (I think they're not bundled even though I added them to the resource config)

Code:

<For each={characters()}>
    {(char) =>
        <div class="card">
            <img src={`avatar/${char.id}/front.png`} />
        </div>
    }
</For>

Config:

"bundle": {
    "resources": [
        "../public"
    ],
},

Am I missing something or is this just broken?

lost saddle
#

Why is it that I keep posting these questions just to randomly fix them myself on accident an hour later 💀

My images where loading correctly but I wanted to load a json file in my dist folder using resolvePath which didn't work. Everything after that resolvePath just didn't load in because of the error. I also found out that images in a css file only load when having an absolute path.

edgy surge
# lost saddle I am trying to load images dynamically from the /public folder, but when I build...

Resources aren't bundled with the app, they are packaged with the installer and unpacked on the filesystem when installed. If you wanna use it like regular web resources bundled you have to place them in your dist dir and make sure you use your frontend frameworks setup for loading css and images from a public folder. If you wanna use it as a Tauri resource you'll indeed need an absolute path to the file using the asset protocol, and should use convertFileSrc to access them

lost saddle