You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update FAQ to include section about inline asset URLs (#898)
* Update faq.md
Update FAQ to include a section about inline asset URLs, as discussed in the following issue: #863
* Update faq.md
Fix some text not showing
* Update faq.md
Add an example to the inline assets section
* Update faq.md
Fix spacing between beginnings of parenthesis
* docs(faq): update entry about relative asset urls
---------
Co-authored-by: dominikg <[email protected]>
Copy file name to clipboardExpand all lines: docs/faq.md
+14
Original file line number
Diff line number
Diff line change
@@ -237,3 +237,17 @@ See the faq about [vite and prebundling](#what-is-going-on-with-vite-and-pre-bun
237
237
> [svelte-package](https://kit.svelte.dev/docs/packaging) which already supports it.
238
238
>
239
239
> For backwards compatibility, you can keep the `svelte` field in addition to the `exports` condition. But make sure that both always resolve to the same files.
240
+
241
+
### How can I use relative paths for asset references in svelte components like `<img src="./asset.png">`
242
+
243
+
This is not supported out of the box. To resolve assets, you have to either import them like this:
244
+
245
+
```html
246
+
<script>
247
+
importassetUrlfrom'./asset.png';
248
+
</script>
249
+
<imgsrc="{assetUrl}" />
250
+
```
251
+
252
+
or use a separate tool to add this functionality.
253
+
The 2 recommended solutions are [sveltejs/enhanced-img](https://kit.svelte.dev/docs/images#sveltejs-enhanced-img) (only for image elements) and [svelte-preprocess-import-assets](https://www.npmjs.com/package/svelte-preprocess-import-assets) (for all asset URLs).
0 commit comments