frandiox / vitesse-ssr-template

🏕 Opinionated Vue + Vite Starter Template with SSR in Node.js
https://vitesse-ssr.vercel.app/
MIT License
188 stars 29 forks source link

How to deploy this template to vercel? #8

Closed yaquawa closed 3 years ago

yaquawa commented 3 years ago

Hi, I have a question about the deployment with vercel. I saw the vercel.json is not in the root of the project, so how to config vercel to make it work?

frandiox commented 3 years ago

@yaquawa There's a script in package.json for that, deploy. It basically moves to serverless folder and invokes vercel CLI.

I'd like to move it to the top but Vercel doesn't seem to support pnpm yet so it had troubles with it.

yaquawa commented 3 years ago

So do you mean the actual git repository connected with Vercel is the serverless directory? and you should manually build the project instead of by pushing to remote branches to trigger the building process via Vercel?

frandiox commented 3 years ago

Ah no, the current structure works for something like GitHub actions or any other CI where you can just run commands.

I'm not sure how Vercel's GitHub integration works. If they require the vercel.json at the root, then I think you can move the whole serverless directory content to the root. You will need to replace pnpm with npm or yarn because the former is not supported in Vercel, as far as I know.

yaquawa commented 3 years ago

Oh, I see the point now! Yes, Vercel requires the vercel.json at the project root, so I guess I have to put the serverless directory to the project root. Thanks for the details!

yaquawa commented 3 years ago

Hi @frandiox , I just want to ask you for another question.. https://github.com/frandiox/vitesse-ssr-template/blob/fa916beb9ae7e29f81a01f6710c577e3898aae1d/serverless/vercel.json#L8-L13 with rewrites set to "source": "/(.*)",, all requests will be rewrites to /api/index.js including the static assets files, how could you solve this problem?

frandiox commented 3 years ago

@yaquawa Hmm, I didn't notice any issue like this in the demo 🤔 I think Vercels gives priority to assets, for example:

I'm not very experienced with Vercel's config, honestly, so this is just my assumption 🤔

yaquawa commented 3 years ago

Thanks for the quick reply @frandiox ! So looks like to make "source": "/(.*)" work properly, all assets should go to the /assets directory .. 🤔 This is tricky, I'm not sure even the assets will be distributed via CDN or the serverless function... 🤔 I also couldn't find any resources about this topic, I have contacted the support team, no responses back for a long time..