How to deploy functions from other directory than '/functions'?
The project workspace that you create with the Firebase CLI contains a file called firebase.json that has a stanza for Cloud Functions that looks like this:
"functions": {
"predeploy": [
"npm --prefix $RESOURCE_DIR run lint"
],
"source": "functions"
}
That "source" property defines the name of the folder that contains the code that will run on Cloud Functions. You can change that to whatever you want.
If you want to use your root directory as your functions folder just change your source
key to .
in your firebase.json
.
"functions": {
"source": ".",
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
This will look for your index.js
file in the root directory (remember to move all the other files to your root directory too).
Documentation: https://firebase.google.com/docs/functions/manage-functions#deploy_functions