-
How can I import images? Since it uses snowpack I was expecting something like this to work out of the box (taken from the official docs): import imgReference from './image.png'; // img === '/src/image.png'
<img src={imgReference} />; neither this worked (same image inside public/ and src/img/ folders): // Trying get relative from public/ (root)
<img src="/image.png" alt="" />
<img src="./image.png" alt="" />
// Trying get relative from src/
<img src="/images/image.png" alt="" />
<img src="../images/image.png" alt="" /> |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Oh, img in JS isn't supported yet? (ref: #65) Putting the image inside the public/ folder and trying |
Beta Was this translation helpful? Give feedback.
-
Thanks for raising this, I'm thinking I'm not handling the |
Beta Was this translation helpful? Give feedback.
-
I created this variable to exclude some types And then added this condition: if (
req.url.indexOf("/web_modules/microsite") === -1 &&
!MIME_EXCLUDE.includes(result.contentType.split("/")[0])
) {
...
} and now it loads assets as expected. Just a side note: I'm building my site, I set out to find any SSG built on top of snowpack that would fit my needs. Found SveletKit and microsite, but they are still young, so I'm building it in another mature framework and copying and pasting in projects with these young frameworks to see what sticks and what doesn't. :) microsite looks promising, looking forward to it! |
Beta Was this translation helpful? Give feedback.
I created this variable to exclude some types
const MIME_EXCLUDE = ["image", "font"];
.And then added this condition:
and now it loads assets as expected.
Just a side note: I'm building my site, I set out to find any SSG built on top of snowpack that would fit my needs. Found SveletKit and microsite, but they are still young, so I'm building it in another mature framework and copying and pasting in projects with these young frameworks to see what sticks and what doesn't. :)
microsite looks promising, looking forward to it!