---
name: index.html の bundle 参照は app.html と同期させる
description: 2026-04-27 重大 bug 発見. vite build は app.html のみ更新するため index.html は古い bundle 参照のまま固まる. rei-aios.pages.dev/ の root URL は index.html を返すので「最新版が見えない」が再発しやすい.
type: feedback
originSessionId: dc134806-8461-4595-93c9-2776f242383c
---
# index.html bundle 参照同期 (永続対策)

**Why:** 2026-04-27 藤本さん screenshot で発覚した重大 bug。

| URL | 返される HTML | 参照 bundle (実態) |
|-----|--------------|-------------------|
| `https://rei-aios.pages.dev/` | index.html | `app-BYnWX6bB.js` (古い) |
| `https://rei-aios.pages.dev/index.html` | index.html | `app-BYnWX6bB.js` (古い) |
| `https://rei-aios.pages.dev/app.html` | app.html | `app-D5HzP5Nd.js` (最新) |

vite.config.ts は `input: 'app.html'` のみ build するため、index.html の bundle 参照は古いまま固まる。
原因: index.html は OGP / Twitter Card metadata 入りで手書き管理、vite が触らない。

ユーザーは root URL `rei-aios.pages.dev/#/automation` を開くため index.html → 古い bundle が読み込まれ「変更が反映されない」と感じる。

**How to apply:**
1. `npm run dev:build` は `vite build && tsx scripts/sync-index-html-bundle.ts` の連結に変更済 (2026-04-27 commit)
2. **手動で `npx vite build` を直接実行する場合は必ず後で `npm run sync:index-html` を打つ**
3. CF Pages deploy 前に必ず index.html の `<script src="/assets/app-XXX.js">` が app.html と一致しているか確認

## Detection コマンド

```bash
diff <(grep -oE 'app-[A-Za-z0-9_-]+\.js' dist-renderer/index.html) \
     <(grep -oE 'app-[A-Za-z0-9_-]+\.js' dist-renderer/app.html)
# 差分があれば sync 必要
```

または:
```bash
curl -sL "https://rei-aios.pages.dev/" | grep -oE 'app-[A-Za-z0-9_-]+\.js'
curl -sL "https://rei-aios.pages.dev/app.html" | grep -oE 'app-[A-Za-z0-9_-]+\.js'
# 同じ bundle filename を返すべき
```

## 教訓

- 「deploy 完了確認」は `app.html` だけでなく **index.html (root URL)** も見る必要がある
- 「ユーザーが見ている URL」と「私が curl で確認している URL」が一致しているか常に確認
- vite の build input が単一エントリの場合、関連 HTML ファイルは別途同期 mechanism が必要
- 2026-04-27 以前の commits (今日の Phase 0 MVP / Phase A/B/C / automation redirect / discovery 拡張) は全て **index.html 経由では見えない状態だった可能性**
