Files
flutter_wisetronic/build_web.sh

25 lines
956 B
Bash
Executable File

#!/usr/bin/env bash
# Flutter Wisetronic — Web 构建脚本
# 用法:
# ./build_web.sh # 构建 release 版本到 build/web/
# ./build_web.sh run # 构建并在 Chrome 中运行调试版
#
# 说明:
# - 必须 --no-tree-shake-icons: 项目中有 24 处 IconData(codePoint) 使用
# 来自 JSON/API 的动态 code point(非 const), icon tree-shaking 无法处理。
# - Dart SDK: 本地 Flutter 3.29.3 / Dart 3.7.2(未升级全局 SDK)。
set -e
cd "$(dirname "$0")"
if [ "$1" = "run" ]; then
echo ">>> flutter run -d chrome --no-tree-shake-icons"
flutter run -d chrome --no-tree-shake-icons
else
echo ">>> flutter build web --no-tree-shake-icons"
flutter build web --no-tree-shake-icons
echo ""
echo "✓ 构建完成: build/web/ (main.dart.js: $(du -h build/web/main.dart.js | cut -f1))"
echo " 本地预览: python3 -m http.server --directory build/web 8080"
echo " 然后访问 http://localhost:8080/"
fi