test
This commit is contained in:
58
08-build-pc.sh
Executable file
58
08-build-pc.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# 08-build-pc.sh — 构建 PC Web 静态产物
|
||||
#
|
||||
# 产物目录: /app/pc/dist
|
||||
# Nginx 配置 deploy-test/nginx/openim-pc-proxy.conf 会直接访问该目录。
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
||||
init_dirs
|
||||
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
set -a
|
||||
# shellcheck source=/dev/null
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
fi
|
||||
|
||||
normalize_pc_proxy_env
|
||||
init_script_log
|
||||
|
||||
header "构建 PC Web 静态产物"
|
||||
|
||||
PC_DIR="$ROOT_DIR/pc"
|
||||
if [[ ! -d "$PC_DIR" ]]; then
|
||||
error "pc 目录不存在: $PC_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v yarn &>/dev/null; then
|
||||
error "yarn 未安装,请先执行: ./deploy-test/00-init-tools.sh node"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$PC_DIR/node_modules" ]]; then
|
||||
error "pc/node_modules 不存在,请先执行: ./deploy-test/06-install-frontend.sh pc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pc_ensure_wasm_assets
|
||||
pc_export_vite_backend_env
|
||||
pc_print_vite_backend_env
|
||||
|
||||
step "执行 yarn build"
|
||||
(
|
||||
cd "$PC_DIR"
|
||||
pc_export_vite_backend_env
|
||||
yarn build
|
||||
)
|
||||
|
||||
if [[ ! -f "$PC_DIR/dist/index.html" ]]; then
|
||||
error "构建失败: $PC_DIR/dist/index.html 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
success "PC Web 构建完成: $PC_DIR/dist"
|
||||
info "Nginx 静态根目录: /app/pc/dist"
|
||||
info "重新加载 Nginx 配置: sudo ./deploy-test/00-init-tools.sh nginx"
|
||||
Reference in New Issue
Block a user