Update - Apparently I was wrong even locally JS was not working until I linked and did a ntl build on my local machine. Do you always have to do a build before a ntl dev to ensure you have all the latest updates? I thought when you deployed your site or did a ntl dev that Netlify did a build on the fly of your current changes? Am I wrong.
You say you’re working with plain vanilla JS, but you also mention building the site and public/dist folders, and I can see your
index.js file ends up as
The behavior you’re talking about would normally be related to whatever site generator system you’re using, what is executing when you run
npm run build?
Sorry for the late response. I’m using Vite. It’s the most curious thing. If I don’t run a ntl link from my local machine first I notice that none of my JS events are attached to my DOM elements. Like I had my script element in the <head> before DOM was built which I don’t. I was under the impression that if I setup my site from Netlify UI I just link my site to my Github account, do a push to main branch, and oila site should be up and working.
@Alan_Killian Have you performed the Vite build locally and confirmed what it results in?
Netlify isn’t performing any magic, so whatever you’re encountering is most likely to be the behaviour of Vite and you should reference their documentation.
When setting up your site in Netlify you do need to specify some basic build configuration.
To simulate the build on Netlify you can execute the same build command locally (e.g.
npm run build), go into the output folder and then run