运行 Firebase 云在本地运行?
Run Firebase cloud functions locally?
是否可以在开发期间在本地 运行 Firebase 云功能?每次进行更改时,都需要很长时间才能部署到 firebase。
谢谢
我觉得你可以用他们的云函数模拟器
更多详情here
firebaser 在这里
Firebase 现在提供 emulator suite,允许您在本地 运行 Cloud Functions 和许多其他 Firebase 产品,以进行本地开发。我强烈建议在部署到生产(甚至暂存)之前将其用于所有本地开发。
上一个回答
更新(2017 年 9 月):自 version 3.11 of the Firebase tools/CLI there is a Cloud Functions shell, which you can use to test your functions locally without deploying them. I recommend reading the blog post Testing Functions Locally with the Cloud Functions Shell and the documentation on how to Run Functions Locally。
更新:从version 3.8 of the Firebase tools/CLI开始,当您运行firebase serve
时,它可以模拟HTTP功能。但仍不支持其他触发器类型。
上一个回答
我们正在努力。与此同时,我将引用 firebase-talk mailing list:
中的 Firebaser Doug 同事的话
Unfortunately, this does not exist today. A local environment for building and testing Cloud Functions is a high priority for the engineering team.
In the meantime, you could abstract away the core functionality of your function and invoke it directly with the node command line, passing in all necessary data that it needs to operate. For example, with an HTTPS function, figure out what you need from the request object, make that the input to another function, then invoke that with dummy data that you create. The response could be handled similarly.
是否可以在开发期间在本地 运行 Firebase 云功能?每次进行更改时,都需要很长时间才能部署到 firebase。
谢谢
我觉得你可以用他们的云函数模拟器
更多详情here
firebaser 在这里
Firebase 现在提供 emulator suite,允许您在本地 运行 Cloud Functions 和许多其他 Firebase 产品,以进行本地开发。我强烈建议在部署到生产(甚至暂存)之前将其用于所有本地开发。
上一个回答
更新(2017 年 9 月):自 version 3.11 of the Firebase tools/CLI there is a Cloud Functions shell, which you can use to test your functions locally without deploying them. I recommend reading the blog post Testing Functions Locally with the Cloud Functions Shell and the documentation on how to Run Functions Locally。
更新:从version 3.8 of the Firebase tools/CLI开始,当您运行firebase serve
时,它可以模拟HTTP功能。但仍不支持其他触发器类型。
上一个回答
我们正在努力。与此同时,我将引用 firebase-talk mailing list:
中的 Firebaser Doug 同事的话Unfortunately, this does not exist today. A local environment for building and testing Cloud Functions is a high priority for the engineering team.
In the meantime, you could abstract away the core functionality of your function and invoke it directly with the node command line, passing in all necessary data that it needs to operate. For example, with an HTTPS function, figure out what you need from the request object, make that the input to another function, then invoke that with dummy data that you create. The response could be handled similarly.