#!/bin/bash # 构建并检查 Agent Chat echo "🏗️ 开始构建..." echo "" # 1. 清理缓存 echo "1️⃣ 清理缓存..." rm -rf node_modules/.cache rm -rf build # 2. 执行构建 echo "" echo "2️⃣ 执行构建(显示详细输出)..." npm run build 2>&1 | tee build.log # 3. 检查构建结果 echo "" echo "3️⃣ 检查构建结果..." if [ -d "build" ]; then echo "✅ build 目录已生成" # 检查 CSS 文件 if [ -d "build/static/css" ]; then echo "✅ CSS 目录存在" echo "" echo "📊 CSS 文件列表:" ls -lh build/static/css/ echo "" echo "📏 CSS 文件大小统计:" for file in build/static/css/*.css; do if [ -f "$file" ]; then size=$(wc -c < "$file") lines=$(wc -l < "$file") echo " - $(basename $file): $size bytes, $lines 行" # 检查是否包含 Tailwind 类名 if grep -q "bg-gray-900" "$file"; then echo " ✅ 包含 Tailwind 类名 (bg-gray-900)" else echo " ❌ 不包含 Tailwind 类名 (bg-gray-900)" fi fi done else echo "❌ CSS 目录不存在" fi # 检查 index.html if [ -f "build/index.html" ]; then echo "" echo "✅ index.html 已生成" else echo "" echo "❌ index.html 不存在" fi else echo "❌ build 目录不存在,构建失败!" echo "" echo "🔍 查看构建日志:" tail -50 build.log fi echo "" echo "📝 完整构建日志已保存到: build.log"