add cf deploy
This commit is contained in:
@@ -7,7 +7,9 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"deploy:pages": "bash scripts/deploy-pages.sh"
|
"deploy:pages": "bash scripts/deploy-pages.sh",
|
||||||
|
"deploy:cf-git": "bash scripts/cf-git-pages-deploy.sh",
|
||||||
|
"deploy:cf": "wrangler deploy"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
|
|||||||
9
scripts/cf-git-pages-deploy.sh
Executable file
9
scripts/cf-git-pages-deploy.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 若必须填 Deploy command:优先填「npx wrangler deploy」(与 wrangler.toml 中 [assets] 配套)。
|
||||||
|
# 云端已跑过 npm run build 后再执行本脚本,无需再 build。
|
||||||
|
set -euo pipefail
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT"
|
||||||
|
PROJECT="${PAGES_PROJECT_NAME:-hgtk-landing}"
|
||||||
|
BRANCH="${CF_PAGES_BRANCH:-main}"
|
||||||
|
exec npx wrangler pages deploy dist --project-name "$PROJECT" --branch "$BRANCH"
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
# Git 集成时的两种常见配置:
|
# Cloudflare(Git 集成 + 必填 Deploy command)
|
||||||
|
# =====================================================================
|
||||||
|
# 供控制台「Deploy command」使用(任选其一,与下面 wrangler.toml 配套):
|
||||||
|
# npx wrangler deploy
|
||||||
|
# npm run deploy:cf
|
||||||
|
# 若更偏向经典 Pages CLI,可使用: npm run deploy:cf-git
|
||||||
|
# Build command 仍为 npm run build;输出目录 dist 会先由构建生成,再由 deploy 上传。
|
||||||
#
|
#
|
||||||
# 1) 仅静态 Pages:Build = npm run build,Output = dist,「Deploy command」留空
|
|
||||||
# (由 Cloudflare 直接发布 dist,勿再执行 wrangler deploy)
|
|
||||||
#
|
|
||||||
# 2) Workers + Vite 管道:控制台会执行 npx wrangler deploy,要求 package.json 中 Vite ≥ 6
|
|
||||||
#
|
|
||||||
# 下面 name 建议与 Cloudflare 控制台里的 Worker / Pages 项目名一致(你当前日志为 hgtk-landing)
|
|
||||||
name = "hgtk-landing"
|
name = "hgtk-landing"
|
||||||
compatibility_date = "2025-05-01"
|
compatibility_date = "2025-05-01"
|
||||||
pages_build_output_dir = "dist"
|
|
||||||
|
|
||||||
# 若 wrangler 提示需要账户 ID,可取消下行注释并填入(或与 CLOUDFLARE_ACCOUNT_ID 二选一)
|
[assets]
|
||||||
|
directory = "./dist"
|
||||||
|
# 客户端路由刷新时回退到 index.html(与 public/_redirects 作用一致)
|
||||||
|
not_found_handling = "single-page-application"
|
||||||
|
|
||||||
# account_id = ""
|
# account_id = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user