While working on a recent tailwind project, I came across this issue. Let me explain it with an analogy.
Let there are 10 divs and 10 img files inside a folder "asset". So, I linked 5 images with 5 divs respectively (1 img inside 1 div), and I linked other 5 images by adding value to .src with the help of Form.array() and for.Each() methods. Now, when I am opening the page with liveserver, I am getting all the 10 images, but when I am running "npm run build" for deployment purposes then those 5 images which I had linked with src are there in the /asset but the rest 5 images( which I was calling via Js) are not.
I get it, that "npm run build" is parsing those file which are directly linked inside html, but rest 5 images are not there, since they are added later on after Js
I have tried adding type="module" attribute and "defer" in the script tag, but nothing seems to work