ENGINEERING WORKFLOW · 73
Cloudflare Static Assets:Source 不是 Production,dist 才是部署 Artifact
Static site deployment 的核心不是「GitHub 直接變網站」,而是 source 經 build 產生 artifact,再由 deployment tool 上傳。Production serving 的是已部署 artifact,不是你尚未 build 的 working tree。
Learning outcomes
- 能畫出 source → dist → deploy → production。
- 能區分 source tree 與 deployment artifact。
- 能理解 route canonicalization / redirect。
- 能用 commit/run/deployment/smoke 建 release evidence。
1. Build boundary
repository source
↓ npm run build
dist/
↓ artifact verification
wrangler deploy
↓
Cloudflare deployment
↓
public workers.dev如果 build script 漏複製某課,source 裡有它也沒用;artifact 裡不存在,production 就無法服務。
2. Deployment config 指向 artifact
assets.directory
= "./dist"實際 config syntax 依 Wrangler 版本而定;核心是不讓 deploy tool 猜「哪個 directory 才是正式輸出」。
3. Canonical URL / redirect
/catalog.html
↓
/catalogStatic hosting 對 extensionless route、trailing slash、fallback 的規則可能不同。Smoke 應驗 production 真實 route,而不是只驗本機 file path。
4. Deployment version 是 release identity
commit SHA
↓
Actions run
↓
build artifact
↓
Cloudflare deployment version這條 chain 讓你回答「線上現在是哪一版」。
5. Public smoke
curl -L -o /dev/null -w "%{http_code}" https://example.workers.dev/catalogArtifact check 驗 build output;public smoke 再驗 platform routing、deployment 與對外可達性。
Project checkpoint:Course Workspace v12
Git commit
↓
CI PASS
↓
dist exact-set verification
↓
manual deploy
↓
deployment version
↓
public smoke PASS至此從 source 修改到 production evidence 成為完整工程閉環。
Debug evidence:GitHub main 更新但網站還是舊版
- Production workflow 是否真的部署 current SHA?
- dist 是否包含修改?
- Deployment version 是否更新?
- Public route 是否正確?
- 最後才考慮 client cache。
Knowledge check
- Source tree 與 dist artifact 差在哪?
- 為什麼 source 有檔不代表 production 有?
- Public smoke 和 artifact check 各驗哪層?
- 畫出 commit SHA 到 deployment version 的 evidence chain。