Skip to content

Commit

Permalink
genrate and use wrangler.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
ZibanPirate committed Sep 28, 2024
1 parent f822f33 commit f43cab2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cloudflare/public/*
**/cloudflare/public/*
**.lighthouseci
.wrangler
**/cloudflare/wrangler.toml

# mobile
mobile/.expo
Expand Down
5 changes: 3 additions & 2 deletions web/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"private": true,
"scripts": {
"build": "lerna run build:alone [email protected]/web --include-dependencies --stream",
"deploy:prd": "wrangler pages deploy --project-name dzcode-dot-io --directory=./public --branch main",
"deploy:stg": "wrangler pages deploy --project-name stage-dot-dzcode-dot-io --directory=./public --branch main",
"generate:config": "npx tsx scripts/generate-config.ts",
"deploy:prd": "npm run generate:config -- production && wrangler pages deploy --branch main",
"deploy:stg": "npm run generate:config -- staging && wrangler pages deploy --branch main",
"dev": "npm run build && wrangler pages dev . --port 8080",
"dev:prepare": "npm run build && cd .. && npm run bundle && npm run pre-deploy",
"lint:eslint": "eslint --config ../../packages/tooling/eslint.config.mjs",
Expand Down
21 changes: 21 additions & 0 deletions web/cloudflare/scripts/generate-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { writeFileSync } from "fs";

// Get the environment passed as argument
const STAGE = process.argv[2];
if (!STAGE) throw new Error("Please provide a STAGE");

console.log(`Creating wrangler.toml ...`);

writeFileSync(
"wrangler.toml",
`
name = ${STAGE === "production" ? '"dzcode-dot-io"' : '"stage-dot-dzcode-dot-io"'}
compatibility_date = "2024-09-28"
pages_build_output_dir = "./public"
[vars]
STAGE = "${STAGE}"
`,
);

console.log(`Done creating .bundle-info.json`);

0 comments on commit f43cab2

Please sign in to comment.