Setting Up Statics Assets
- Set up the repo on Github
- Assign the repo to Cloudflare (and Replit). Github->Settings->Applications. You will get an error after you save the connection. Just ignore it.
- Log into Replit and create the codebase by importing from Github. Add this to .replit:
run = "npm run dev"
[[ports]]
localPort = 8787
externalPort = 80
exposeLocalhost = true
- Run
npm install
in shell in Replit. - Set up Replit secrets - you can copy from another worker in Replit.
- Refresh Replit , close that replit and open it again, so the secrets work
- Run
npx wrangler deploy
- this will publish this worker to cloudflare.npx wrangler deploy --env production
for production branches. See below. - Go to the worker and connect to the repo and set up logs. (see package.json and wrangler.toml of existing static sites.
- Environments: You should set up different branches in github, i.e. dev, main. Then for Cloudflare you set up different environments in your workers and you assign each environment (first publish per the npx step above), and assign the live to main branch etc. Important is that the build command on the cloudflare dashboard for production needs to be: npx wrangler --env production. For the dev branch, you can do regular npx wrangler deploy or use whatever environment you are using for dev.