Search code examples
functionfirebasegoogle-cloud-functionsfirebase-toolsgoogle-cloud-tools

Cloud Functions for Firebase: Project structure multiple self-contained functions


I am trying to create a project structure similar to the following:

--firebase-admin-project
  --firebase.json
  --functions
    --anonymous-login
      --node_modules
      --index.js
      --package.json
    --auth-login
      --node_modules
      --index.js
      --package.json

The intention is to do "firebase deploy --only functions" in either the anonymous-login or auth-login folders but the deployment fails.

Currently, "firebase init functions" creates new index.js and package.json files in the functions folder, which is not what I want.

Also, we want to avoid using require to pull all functions into one index.js file.


Solution

  • When you run firebase deploy, it will deploy every function in your project and all files under the functions directory. There is currently no way to select anything less than the entire thing.

    Update: There is a new feature in the CLI that allows for individual functions and groups of functions to be deployed independently. The documentation for that is in the partial deploys section of the docs.