Why is it important to use a file loader while I can use the absolute path for my file? say image for example...
In this case, I want to use an image called img.jpg
:
import myImage from "../assets/img.jpg"
function addImage(src) {
const image = document.createElement("img");
image.alt = "our image";
image.src = src;
const body = document.querySelector("body")
body.appendChild(image)
}
addImage(myImage)
This code wouldn't work without a file loader but if I use the path of the image, that would work...
addImage("./dist/kemo.jpg")
So, I ask here why the file loader is important if I can dispense of it?