Home > Software engineering >  Firebase Functions multiple directories - Nuxt 3 / Nitro
Firebase Functions multiple directories - Nuxt 3 / Nitro

Time:09-11

I'm experimenting with Nuxt 3 on Firebase hosting and have a basic build deployed successfully. However, it has taken over the functions directory.

Is it possible to specify a second directory in firebase.json? Thanks.

Here is the relevant portion of my working-for-nuxt firebase.json file.

"functions": {
    "source": ".output/server",
    "runtime": "nodejs14",
    "ignore": [
      "node_modules",
      ".git",
      "firebase-debug.log",
      "firebase-debug.*.log"
    ]
  },

CodePudding user response:

Nuxt 3 creates a single function ("server") and deploys to Cloud Functions. If you want to deploy functions from another source directory as well e.g. for Firestore triggers then you can pass an array to functions property in the firebase.json as shown below:

{
  "functions": [
    { "source": ".output/server", "codebase": "nuxt_app" },
    {
      "predeploy": "npm --prefix \"$RESOURCE_DIR\" run build",
      "source": "functions",
      "codebase": "cloud_functions"
    }
  ]
}

Checkout the documentation to learn more about Managing multiple source packages.


If you are not using background functions like Firestore or Cloud Storage triggers and just using HTTP callable functions, then you can use NuxtJS Server Routes to deploy HTTP endpoints.

  • Related