From bf7402820054941119e38fbd69081fe00e146c54 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sat, 2 May 2026 12:54:29 -0600 Subject: [PATCH] Fix medal icon CORS errors by inlining SVG as data URI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CSS mask-image triggers a CORS fetch, which failed for the CDN-hosted medal SVG. Switched to a Vite ?raw import so the SVG is embedded as a data URI at build time — no network request, no CORS. Also stripped the SVG of Inkscape metadata and replaced filter-based color inversion with a plain fill="white", shrinking it from 3,278 → 955 bytes (387 bytes gzipped). --- resources/images/MedalIconWhite.svg | 89 +------------------------ src/client/components/map/MapDisplay.ts | 6 +- 2 files changed, 7 insertions(+), 88 deletions(-) diff --git a/resources/images/MedalIconWhite.svg b/resources/images/MedalIconWhite.svg index ef9fe4154..e6cb2a9c1 100644 --- a/resources/images/MedalIconWhite.svg +++ b/resources/images/MedalIconWhite.svg @@ -1,87 +1,4 @@ - - - - - - - - - - - - - - - + + + diff --git a/src/client/components/map/MapDisplay.ts b/src/client/components/map/MapDisplay.ts index 5e83687d2..d86da025e 100644 --- a/src/client/components/map/MapDisplay.ts +++ b/src/client/components/map/MapDisplay.ts @@ -1,10 +1,12 @@ import { LitElement, html } from "lit"; import { customElement, property, state } from "lit/decorators.js"; -import { assetUrl } from "../../../core/AssetUrls"; +import medalIconRaw from "../../../../resources/images/MedalIconWhite.svg?raw"; import { Difficulty, GameMapType } from "../../../core/game/Game"; import { terrainMapFileLoader } from "../../TerrainMapFileLoader"; import { translateText } from "../../Utils"; +const medalMaskUrl = `url('data:image/svg+xml;utf8,${encodeURIComponent(medalIconRaw)}') no-repeat center / contain`; + @customElement("map-display") export class MapDisplay extends LitElement { @property({ type: String }) mapKey = ""; @@ -144,7 +146,7 @@ export class MapDisplay extends LitElement { const wins = this.readWins(); return medalOrder.map((medal) => { const earned = wins.has(medal); - const mask = `url('${assetUrl("images/MedalIconWhite.svg")}') no-repeat center / contain`; + const mask = medalMaskUrl; return html`