Error in vite packaged web site

I have been migrating a Web site from Aurelia 1 to Aurelia 2. I used this template as a base. After migrating 20 or30 pages I tested the producuction deployment and it seemed OK. Now after adding quite a few more pages I have found that the production deployment doesn’t work, but in dev it works fine. First I had this issue with vite/rollup and had to add esbuild: { target: es2022’ }. That got me one step further in the production deployment, which is just using vite build.

Now I am getting an error in the runtime-html when it tries to add an event listener. The issue seems to be that app isn’t seen as a custom-element. The metadata is missing the au:resource:custom-element (and au:resource) and only has au:annotation:di:parameters and au:resource:route-configuration, so when it checks to see if app is a custom element it isn’t one and doesn’t set the host.

I should have made more snapshots as I went, because then I could more easily narrow down what caused this to break. Before spending too much time trying to figure out what might be causing this, I thought it would be a good idea to ask for help narrowing down the problem. Any suggestions on how I can figure out what is causing this? Maybe look for the code that builds the metadata?