gurvancampion / turborepo-nuxt-boilerplate

Nuxt.js 3 x Histoire x Vitest x VitePress x Turbo (pnpm)
MIT License
102 stars 15 forks source link

How to deploy to Netlify or Vercel? #345

Closed RobErskine closed 1 year ago

RobErskine commented 1 year ago

I am trying to deploy the Nuxt frontend (apps/web) to Netlify or Vercel, and while both are "deploying" successfully, both result in 404s. I see in apps/web/nuxt.config.ts that Nitro is set to Netlify, so I have to image this is possible, but maybe my build commands are off?

nitro: {
  preset: 'netlify'
}

I also see that there is some references to environment variables for Netlify in .github/workflows, but I'd rather set everything up directly in Netlify.


Here is my config set up in Netlify:

Runtime: Not set
Base directory: /
Package directory: apps/web
Build command: turbo run build --filter @myturborepo/web
Publish directory: apps/web/.nuxt/dist
Functions directory: netlify/functions

Is there something silly I am missing here?

RobErskine commented 1 year ago

So I adjusted the default settings that Netlify/Vercel populated with and I was able to get it working with this:

Runtime: Not set
Base directory: /
Package directory: apps/web
Build command: cd apps/web && npm run generate
Publish directory: apps/web/dist
Functions directory: netlify/functions

This works but... is this set up optimal? Happy to update the README.md or docs across the board in case anyone else runs into this. Feel free to close if you'd like.

Thanks for the project, by the way!

RobErskine commented 1 year ago

Dropped in a PR to update the build command for generate utilizing turbo in #346!

gurvancampion commented 1 year ago

Hi @RobErskine, sorry for the late reply. I haven't checked this repository for a while.

As far as I remember I encountered some issues while deploying on Netlify due to the fact that it's a monorepo. You need to make sure that the path for the dist folder is correct. I would assume both build commands turbo run build --filter @myturborepo/web and cd apps/web && npm run build should work but maybe I'm wrong.

Thanks for the PR!