#!/bin/bash
# web-artifacts-bundle —— 在当前 web-artifacts 项目目录里用 Parcel 打单文件 HTML.
# 跳过 `pnpm add -D parcel ...`（模板已预装）和 `.parcelrc` 生成（模板已备好）.
set -e
if [ ! -f package.json ]; then echo "❌ run from project root" >&2; exit 1; fi
if [ ! -f index.html ]; then echo "❌ index.html missing" >&2; exit 1; fi
rm -rf dist bundle.html
pnpm exec parcel build index.html --dist-dir dist --no-source-maps
pnpm exec html-inline dist/index.html > bundle.html
echo "✅ bundle.html ready ($(du -h bundle.html | cut -f1))"
