I have an existing web app consisting of plan HTML, Javascript and CSS, and a back-end web server.
Is it possible to use capacitor in this setting? Are there any official examples?
When I follow the instructions and run npm init @capacitor/app, the default template is a vite app, this app starts its own HTTP server.
However, my plain Javascript wants to talk directly to the backend server and does not need a vite/React middle layer. I imagine I could configure Vite/React to basically proxy requests to the backend, but I'd like to know if this can be avoided.
Is there any official guidance on using capacitor with plain apps?
I've seen this article suggesting the use of webpack, which looks promising. But I'd like to know if there's any official guidance and support for using plan JS without a framework.
Vite is the default dev server of Vue/React; that's why you got it.
If your app is just JS/HTML CSS, make sure it's in a folder like src, and configure your capacitor config: https://capacitorjs.com/docs/config
webdir to be src.
Then, when your code is ready, do npx cap copy this command, will copy your code into the right place in each mobile app folder.
Each time you update your HTML CSS JS, you need to run this command and then build the mobile app.
Hope that help.
Vite is just a dev server that helps you do live reload instead of copying manually after each change. Webpack is the same as Vite, but Vite is more modern.
Vite is not a middle layer between the front and your backend; it's a build tool. https://vite.dev