Hello I'm trying to dynamically import a file and if it doesn't than I'm going to create it. But how can I import it only if it exists? This code is throwing me a 500 server error when I try to import a not existing yet file. This is my code (I'm using Vite to serve my app)
import(`./../Cache/${component.type.name}.svg?raw`)
.then(svgCode => console.log(svgCode))
.catch(err => {
//here the file is created if it doesn't exists but it still throwing an error in the console
})
It's not only about the error in the console, Vite is also throwing me this message:
ENOENT: no such file or directory, open '/Atlantide/SvgRender/Cache/PixelGrid.svg' Click outside or fix the code to dismiss. You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
But I don't wanna disable HMR in my setup, any advice?