Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

img tag is working locally but not in preview environment in Svelte [duplicate]

$
0
0

First time using Svelte and I'm just using a simple img tag seen below:

<img src="src/lib/assets/todo_list.png" alt="todo list"/>

When I run npm run dev, it shows up locally fine in browser. When I run npm run build and then npm run preview. The preview environment can't find the image.

[can't find image1

What am I missing? Below is the folder directory. Directory

Solutions tried:

  1. Creating my own public/static/ directory and putting the image there

  2. importing seen below, the image will appear for one brief second and then the rest of my site would go blank.

    import userSrc from '$lib/assets/todo_list.png';<img class="mx-auto h-screen" src={userSrc} alt="BONSAI"/>
  3. I have tried changing the src to:

    src="src/lib/assets/todo_list.png"

    src="./lib/assets/todo_list.png"

    src="/lib/assets/todo_list.png"

    src="lib/assets/todo_list.png"

    src="./assets/todo_list.png"

    src="/assets/todo_list.png"

    src="assets/todo_list.png"

    src="./todo_list.png"

    src="/todo_list.png"

    src="todo_list.png"


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>