I have a vanilla JS application. I'm using Vite as a frontend build tool.
<script src="./src/main.js"></script>
<input type="button" value="Connect" onclick="connect();" />
The code above works locally, but when it builds, it does NOT produce JS file in the dist
folder (which I set to deploy), and hence the program errors when deployed.
The error is Uncaught ReferenceError: connect is not defined at HTMLInputElement.onclick
How can I solve this? I deployed it to Firebase hosting using Vite to build.
Edit:
I moved main
branch to Svelte so it works, but vanilla js does not work, which is in the petite-vue
branch. If you want to test it out for the error, please check out this branch.
The source code is here https://github.com/leochoo/emotion/blob/petite-vue/index.html
I think your project is a bit messed, I made you a working example vite + svelte + microbit
available on Github :
Just clone the repo, then run yarn
and yarn build