Files

77 lines
2.2 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# =============================================================================
# 企微IT智能服务台 — 前端构建脚本
# =============================================================================
# 说明:构建坐席工作台和 H5 用户端两个前端项目
# 用法:bash scripts/build.sh
# 输出:frontend-agent/dist/ 和 frontend-h5/dist/
# =============================================================================
set -e # 遇到错误立即退出
echo "=========================================="
echo " 企微IT智能服务台 — 前端构建"
echo "=========================================="
# 获取项目根目录(脚本所在目录的上一级)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
# --------------------------------------------------
# 1. 构建坐席工作台(frontend-agent
# --------------------------------------------------
echo ""
echo "[1/2] 构建坐席工作台..."
cd "$PROJECT_DIR/frontend-agent"
# 安装依赖(如果 node_modules 不存在)
if [ ! -d "node_modules" ]; then
echo " → 安装依赖..."
npm install
fi
# 构建生产版本
echo " → 构建中..."
npm run build
# 验证构建产物
if [ -d "dist" ]; then
echo " ✅ 坐席工作台构建完成: frontend-agent/dist/"
else
echo " ❌ 坐席工作台构建失败: dist/ 目录不存在"
exit 1
fi
# --------------------------------------------------
# 2. 构建 H5 用户端(frontend-h5
# --------------------------------------------------
echo ""
echo "[2/2] 构建 H5 用户端..."
cd "$PROJECT_DIR/frontend-h5"
# 安装依赖
if [ ! -d "node_modules" ]; then
echo " → 安装依赖..."
npm install
fi
# 构建生产版本
echo " → 构建中..."
npm run build
# 验证构建产物
if [ -d "dist" ]; then
echo " ✅ H5 用户端构建完成: frontend-h5/dist/"
else
echo " ❌ H5 用户端构建失败: dist/ 目录不存在"
exit 1
fi
echo ""
echo "=========================================="
echo " 构建完成!"
echo " 坐席: frontend-agent/dist/"
echo " H5: frontend-h5/dist/"
echo "=========================================="
echo ""
echo "下一步: bash scripts/deploy.sh 启动服务"