Mirrors the GitLab pipeline — typecheck, tests, feed sanity — and adds a Pages deploy. Pages serves from /<repo>/, and the app used absolute asset paths, so that job would have shipped a site that 404s on everything. Assets now resolve against a <base href> the build substitutes, the feed URL resolves against document.baseURI so deep links work too, and the service worker derives its paths from its own registration scope. Root-hosted builds are unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
25 lines
827 B
TypeScript
25 lines
827 B
TypeScript
import { StrictMode } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { App } from "./App.tsx";
|
|
|
|
const root = document.getElementById("root");
|
|
if (root === null) throw new Error("#root is missing from index.html");
|
|
|
|
createRoot(root).render(
|
|
<StrictMode>
|
|
<App />
|
|
</StrictMode>,
|
|
);
|
|
|
|
// Offline support. Registered after render so it never delays first paint, and
|
|
// guarded because file:// and older browsers have no service worker at all.
|
|
if ("serviceWorker" in navigator && location.protocol.startsWith("http")) {
|
|
window.addEventListener("load", () => {
|
|
const swUrl = new URL("sw.js", document.baseURI);
|
|
void navigator.serviceWorker.register(swUrl).catch(() => {
|
|
// An unavailable worker costs offline support, nothing else. The app
|
|
// works exactly as before.
|
|
});
|
|
});
|
|
}
|