Home
Support Forums

Javascrip Not work when deploy

My javascript not working when deploy, but in live server it’s ok.

I have javascript for mobile menu button and slide testimoni. You can check my page https://rose-baker.netlify.app/

and see my code in

I think no error in my deploy, but javascript still not working

Hi @sandys

Looking at Static Asset Handling in the Vite guide, I moved the img directory and app.js file into a new public directory.

When Vite builds your site, it copies assets in public without modification into the dist directory.

1 Like

hi @coelmay

I’m make assets directory and move img and app. js. and that’s right when vite build site it copies assets in public.

but, still don’t solve my problem. Javascript stiil not work. or maybe I’m wrong to define “a new public directory” ?

I see you made an assets directory, not a public directory. As per the documentation

The directory defaults to <root>/public , but can be configured via the publicDir option.

If you wish to use assets then you need to create a vite.config.js with publicDir option set to assets.

2 Likes

ohh, I see. I change assets directory to public directory.

It’s Solve my problem.

Thankyou.

1 Like