vercelsveltekitturborepo

404 NOT FOUND when deploying sveltekit to vercel using turborepo, when 100% turborepo cache hit


I have a turborepo with several sveltekit web apps in it. I am using caching. If one of my web apps is triggered for deployment by a repo change, and it gets a 100% turborepo cache, I get this 404 page:

enter image description here


When I turn on directory listing, just to see whats in the directory, I see this:

enter image description here

And this is my vercel deployment configuration for the app:

enter image description here


The web app itself is this one - https://github.com/cozemble/monorepo/tree/main/frontend/ai-playground , so you can see all my configuration files.

When a deployment to this app is triggered by a change to the app itself (meaning turborepo caching does not happen) then it deploys fine.

Update 1 in reponse to the question from @paulogdm, if I remove the Output Directory override, and restore it back to public, I get this deployment error when I deploy a fully cached turborepo build:

enter image description here


Solution

  • Ok, it looks like there are two parts to fixing this:

    1. revert the Output Directory override I did, so it defaults back to public
    2. Add ".vercel/**" to your list of build outputs in turbo.json. Mine now looks like this:
    {
      "$schema": "https://turborepo.org/schema.json",
      "pipeline": {
        "build": {
          "dependsOn": ["^build"],
          "outputs": ["dist/**", "package/**", ".svelte-kit/**", ".vercel/**"]
        },
        "test": {
          "dependsOn": ["build"],
          "outputs": [],
          "inputs": []
        },
        "cypress": {
          "dependsOn": ["build", "test"],
          "inputs": ["cypress/**"],
          "outputs": []
        }
      }
    }
    

    Super non-obvious, but there you go.