firebase deploy --only functions overrides existing functions
Solution 1
You can use firebase partial deploys
$ firebase deploy --only functions:makeUppercase
Will only deploy makeUppercase
function.
Hope it helps.
Note: To deploy more than one function at once (but not all) use:
$ firebase deploy --only functions:function1,functions:function2
Solution 2
firebaser here
Running firebase deploy
will deploy all functions in the project. There is currently no option to deploy just new or modified functions.
It does sound like a useful addition though, so you might want to file a feature request.
Update: since version 3.8 of the Firebase tools CLI this is possible. See Pablo's answer or the release notes.
Solution 3
Make sure you are editing the functions in your "functions/src" directory and not the functions in your 'lib' directory. I made this mistake and watched them get replaced...
Comments
-
Quan Vuong almost 2 years
Running
firebase deploy --only functions
deletes the existing functions before creating new ones. Is it possible to modify this behavior tocreate if not exist, update if exists, no actions if functions not being deployed
? -
Quan Vuong about 7 yearsThanks Frank. You have helped me out more than once :)
-
Quan Vuong about 7 yearsfeature request filed. Thanks for the link!
-
Quinn Turner about 7 yearsI could use some help with this! I would like to deploy multiple functions as well. I have set up my project structure exactly like github.com/firebase/functions-samples has. In fact, I used it as a base, stripped all but two functions, modified, and want to deploy. I have tried firebase deploy, firebase deploy --only ..., and comma separated attempts.
-
Quinn Turner about 7 yearsIf I run "firebase deploy" from root I get that it couldn't locate firebase.json. My guess is I have to restructure the applications, but I haven't had any luck after trying a few alternatives.
-
Scott about 7 years@QuinnTurner Try running
firebase init
, which will add all necessary files. -
Frank van Puffelen about 7 years@QuinnTurner please don't post new questions in a comment. If you have a new problem, post a new question. Be sure to include the minimal code that reproduces the problem in that question (and read the link, it's quite useful).
-
Thorbjørn Kappel Hansen over 6 yearsIt's also possible to deploy multiple functions in a partial deploy:
firebase deploy --only functions:function1,functions:function2
-
Simon Moshenko over 5 yearsI believe the best solution would be using groups, also seen in the documentation link.
-
Ramesh Vishnoi over 3 yearsThanks. This saved lot of time
-
Mars2024 almost 2 yearsBut how should you actually NAME your firebase functions? What does it Actually look like?