Everythings works fine in dev, but the moment I do npm run build and generate the dist folder, and try to run that i get a error “require is not defined”.
And the app crashes.
Adding commonjsOptions: { transformMixedEsModules: true } to the build option of Vite config should fix this issue. Please refer to this Stack Overflow thread for more information about the same.