I have this stenciljs component which uses an svg images like this:
...
return (
<button>
<img src="../../assets/icon.svg"/>
<slot/>
</button>
);
...
My folder structure is
src/
assets/
icon.svg
components/
button/
button.tsx
Now, when I do stencil build
it creates the dist
folder with everything in it.
I copy the dist folder into my site, which has the following structure:
my-web/
index.html
bundle/
<content from dist>
And inside the index.html I load the bundle
<script src="/bundle/my-componets.js"></script>
This works as expected but the asset is loaded from /assets/icon.svg
which does not exist (404). Any suggestions what I need to do to fix this?
From what you intend to do, I understand your goal is to have fully runnable standalone application inside
./dist
after build.All sourcefiles which are needed to run the application should be placed there.This means you will need to create a copy of the sourcefiles (staticfiles) into the distribution folder in the way
my-web/assets/icon.svg
in order for the application to locate and access it.