Deploying a VITE+Solid app
Hi,
I have been trying to deploy a SPA made using Vite + Solid for production. I wanted to create docker images for easy deployment. I already have nix setup for my development environment. I have my docker setup like follows:
I am currently using CapacitorJS along with these to export for ios and android platforms as well(
bunx cap sync
). My end goal is to create a PWA from this codebase.
I do have index.html
in the root which loads src/index.tsx
using <script></script>
that has the render
function. The application works perfectly fine when I do bun dev
to build and serve for development.
Right now, I am having a problem where bunx vite preview
and serving through nginx serves me only a white blank screen. I can see small activity in the network tab but no ERROR at all. Please see the pictures.3 Replies
Just to clarify that its not rehitting caches, I also tried opening this using a different browser and private window.
Major problem is that
bunx --bun vite preview
does not serve the files properly even if I did bunx cap sync
before previewing.
Ill add my package.json
for reference as well:
For super easy deployment, you can use something like Cloudflare pages, Vercel, Netlify.
Then you don't need to create a docker image.
The docker and docker-compose setup probably adds unnecessary complexity.
Where are you deploying to?
With SPA's usually this is deployed to some object storage like S3 which would have higher uptime and is probably cheaper than a running a server
yeah, ty for reply. did not see this. Well, this was a project I wanted to hand over but they asked for docker as they are hosting in their own servers.
Anyways, I figured out the problem. It was the store which was not passed using Context API. I rewrote the definition using context api and it works perfectly fine now. Ty
That was a very weird behaviour where the dev server just works with no issues when I am not at all using context api. The same codebase with 0 changes when builds for deployment behaves entirely differently.