Can we please get a response from the developers, along with either a blog post or a documentation page about how to handle image local assets - images, Javascript includes etc - as there is little to no documentation on how to include a JS library or even a local image.
Even the ion-img documentation cops out of providing example src attributes that might have been helpful.
So far, adding local images to my src/assets folder works using ionic serve, but will only work when running on a device if the leading slash is left off the path.
<!-- This works in a page template on ionic serve & running on device -->
<img src="assets/myimage.png">
<!-- This doesn't work in index.html on a device -->
<script src="assets/myscript.js"></script>
I still havenāt managed to include a JS library into index.html from my assets folder in the same way that worked with an image though - why does this work inconsistently?
Some libraries - older ones specifically - while working with things like google maps and any of the utility libraries, simply need to be included, as they add their goodness to the window object directly. And you canāt import them - theyāre not built for module loaders.
Please please please (pretty please) can we get a response on this from the developers as iāve seen thread after thread and itās actually causing me to have to delay the push of one of my apps to a client.
But itās also not a thing that tends to pop up here in the forum over and over again. Some people work with relative or absolute paths for assets which tends to work in ionic serve but not on devices or vice versa, but besides that not many people seem to have a problem here. So I am looking forward to exactly what is going wrong for you.
Yeah, itās in src/assets/scripts/myscript.js actually, would putting it into a subfolder of src/assets have anything to do with it?
Iāve hit this issue on several different apps now - apologies to the moderators if my wording came across as heavy handed, the threads iāve seen about this have been on Stack Overflow as well as this forum, iāll dig out some links later so it doesnāt just look like iām poking the fire.
You mentioned ion-img. Please note that itās only intended for use with virtual scroll. People frequently overlook that and try to use it as a generic replacement for img, which doesnāt go well.
Ionic really wants you to do this via npm so that it can be included smoothly into the app bundle. If you absolutely canāt find an npm package containing the functionality you want, you can use npm init to npmify what you do have, and npm link to install it locally.
So what exactly did you do wrong in the first post/project? Select your post as the āsolutionā for this topic, then future readers can also benefit from your learnings.