diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index c694e3e..c35bd7d 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -36,8 +36,11 @@ window.__WORDLOOP_RUNTIME__ = { const withoutModule = html .replace(/\s+crossorigin(="[^"]*")?/g, '') .replace(' - +
- + + diff --git a/ios/scripts/build-web-assets.sh b/ios/scripts/build-web-assets.sh index a929ef3..6abc63d 100755 --- a/ios/scripts/build-web-assets.sh +++ b/ios/scripts/build-web-assets.sh @@ -18,29 +18,33 @@ cp -R dist/* "$OUT/" python3 - <', f"") -html = html.replace( - '', - "", -) -# 脚本放在 前,确保 #app 已存在(head 内联会导致 Vue mount 失败、白屏) -html = html.replace( - "", - f" \\n ", -) +# 保持外链资源,避免把 ~1.4MB JS 内联进 HTML 导致 WebKit std::overflow_error 崩溃 +html = html.replace("wordloop://app/assets/", "./assets/") + +script = re.search(r'', html) +if script: + tag = script.group(0) + if tag not in html.split("", 1)[-1]: + html = html.replace(tag, "", 1) + html = html.replace("", f" {tag}\n ", 1) html_path.write_text(html, encoding="utf-8") -print(">>> 已内联 app.js / app.css 到 index.html") + +if len(html) > 20_000: + raise SystemExit("index.html 过大,可能仍含内联 JS,会导致 WebKit overflow 崩溃") +for block in re.findall(r"", html, re.DOTALL): + if len(block) > 1000: + raise SystemExit("index.html 检测到内联业务脚本,请保持 app.js 外链") +if "./assets/app.js" not in html: + raise SystemExit("index.html 缺少 ./assets/app.js 外链") + +print(">>> 已生成外链版 index.html(app.js / app.css 独立文件)") PY echo ">>> 已复制到 $OUT"