Cloudflare Workers - Workflow
Generally, Cloudflare Workers can be written locally, deployed with serverless, and tested with the
serverless invoke command. However, using the Cloudflare Workers Playground can help you test and view your worker’s results live if you need more insight while developing your Cloudflare Worker.
Below is a list of general tips for developing Cloudflare Workers with Serverless.
Write your functions
serverless deploy only when you've made changes to
serverless.yml and in CI/CD systems.
serverless deploy -f myFunction to rapidly deploy changes when you are working on a specific Cloudflare Workers Function.
serverless invoke -f myFunction to test your Cloudflare Workers Functions.
- For Non-Enterprise Cloudflare customers, combining multiple workers into one file or using webpack.
- Keep the Functions and Resources in your Serverless Services to a minimum.
A handy list of commands to use when developing with the Serverless Framework.
Create A Service:
Creates a new Service:
serverless create -p [SERVICE NAME] -t cloudflare-workers
Use this when you have made changes to your Functions, Events or Resources in
serverless.yml or you simply want to deploy all changes within your Service at the same time.
Use this to quickly overwrite your Cloudflare Workers Functions, allowing you to develop faster if you have an Enterprise account that supports deploying multiple functions.
serverless deploy -f [FUNCTION NAME]
Invokes a Cloudflare Workers Function.
serverless invoke -f [FUNCTION NAME]