Fix medal icon CORS errors by inlining SVG as data URI

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).
This commit is contained in:
evanpelle
2026-05-02 12:54:29 -06:00
parent 22dbc4fbb8
commit bf74028200
2 changed files with 7 additions and 88 deletions
+4 -2
View File
@@ -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`<div
class="w-5 h-5 ${earned ? "opacity-100" : "opacity-25"}"
style="background-color:${colors[