bundle unused functions in vite js

hi I’m using vite for bundle my javascript codes and moudules in vanilla js

it’s ok when i run in dev mode
but when i build the code there is two problems

first
i have some functions that aren’t called directly in code and when i build the code they aren’t export to final js file

this is how i call my function in a loob

eval(routes[routesKey]+'(fn(currentRoute))')

and the secound problem is i have some html files and i use them by a fetch in my code and after build the html files are not in dist directory

export function home(pathData){
document.querySelector('title').innerText = "Home"
fetch("/pages/home.html").then(response => {return response.text()} ).then(text =>{
    document.getElementById('main').innerHTML = text
})

}