Import class from public folder "./"

Hello,

I’m trying to import a js class I’ve made into the main file:

the error says it does not exist, if I took the file outside the ‘public’ folder it worked, but I need to keep things organized.

If I changed the path to ‘/classes/testClass.js’ it throws the error “Cannot import non-asset file /classes/testClass.js which is inside /public.JS/CSS files inside /public are copied as-is on build and can only be referenced via or in html”

Thanks

public is for static files, you can’t import from it. you import local modules from /src normally. where is your src folder, did you delete it?

1 Like

@drcmda I’m using vite, it does not create a src folder

Vite file packager doesn’t create a src folder, but I created one and it worked. I also run “npm run build” and everything works as intended.