vite-go
vite-go copied to clipboard
VueGlue implies vue support, what should I use for svelte?
Trying out the repo with a svelte app. Confused as to how to set it up.
It's actually the same as with Vue or React.
First, let's make sure you actually need vite-go. If you're developing a single page application where you're using a Go backend for the API, you don't really need to use this module. You can just use Vite directly, possibly setting up Vite to proxy over to your Go api server.
The best reason to use the module is if you're developing a Go web app that uses Go's templating system, and you want to enhance that UI with Svelte; vite-go makes this pretty easy. Is that what you're trying to do?
No, I do not really need the templating part. I just want to streamline the development and deployment flow of a svelte frontend with go-gin backend.
I'm assuming that go-gin exposes a REST backend (haven't used gin yet myself). So you probably just need to set up Vite as a proxy server for your gin API. Here's the place to start with in the docs.
I was thinking more towards a) getting vite to proxy when under dev and using the built code as a static route when built for production. b) getting both of those to auto-reload
It's actually the same as with Vue or React.
First, let's make sure you actually need vite-go. If you're developing a single page application where you're using a Go backend for the API, you don't really need to use this module. You can just use Vite directly, possibly setting up Vite to proxy over to your Go api server.
The best reason to use the module is if you're developing a Go web app that uses Go's templating system, and you want to enhance that UI with Svelte; vite-go makes this pretty easy. Is that what you're trying to do?
Why is it optimal to proxy requests via vite? My use case is I want to eliminate the need for 2 servers, where go does what vite does for SSR while being the API endpoint. Correct me if this is out of scope
Why is it optimal to proxy requests via vite?
Mostly this prevents the browser from getting annoyed by cross-domain requests during development. You can certainly configure this yourself, but it's kind of a PITA. Having Vite handle this for you eliminates this problem.
My use case is I want to eliminate the need for 2 servers, where go does what vite does for SSR while being the API endpoint. Correct me if this is out of scope
I'm guessing you mean this feature of Vite. I'll admit I'm not familiar with this feature, so I'm not sure if it's "in scope" or not :-). Unless you mean instead using vite-go to render a production build?