I have no idea why setting img.src with import is fine but when I pass the path to it doesn't work.
import mahjong_tiles from '../assets/mahjong_tiles/1man.png'
const displayTileArr = () => {
var img = document.createElement('img');
img.src = mahjong_tiles ; //OK
img.src = '../assets/mahjong_tiles/1man.png'; //NOT OK
document.getElementById('display-hand').appendChild(img);
}
Finally, I got the answer. it seems the .default is essential function to convert the url.
img.src = require('../assets/mahjong_tiles/1man.png').default;
check the path again, works fine for me. enter image description here