Skip to content

Commit 15f74ad

Browse files
committed
Fix relative path problem in patched dsfr.css
1 parent b0e7df6 commit 15f74ad

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/bin/css_to_ts/icons.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Icon } from "./css_to_ts";
22
import { exclude } from "tsafe/exclude";
3-
import { join as pathJoin } from "path";
3+
import { join as pathJoin, sep } from "path";
44

55
type IconLike = Icon.Dsfr | Omit<Icon.Remixicon, "rawSvgCode">;
66

@@ -107,5 +107,16 @@ export async function getPatchedRawCssCodeForCompatWithRemixIcon(params: { rawCs
107107
})
108108
.filter(exclude(undefined));
109109

110-
return css.stringify(parsedCss).replace(/fr-icon-/g, "ri-");
110+
const back =
111+
new Array(
112+
pathOfPatchedRawCssCodeForCompatWithRemixIconRelativeToDsfrDist.split(sep).length - 1
113+
)
114+
.fill("..")
115+
.join("/") + "/";
116+
117+
return css
118+
.stringify(parsedCss)
119+
.replace(/fr-icon-/g, "ri-")
120+
.replace(/url\("/g, `url("${back}`)
121+
.replace(/url\('/g, `url('${back}`);
111122
}

test/runtime/bin/icons/getPatchedRawCssCodeForCompatWithRemixIcon.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ it("Successfully generates patched css for remixicon support", async () => {
103103
-webkit-mask-size: 100% 100%;
104104
mask-size: 100% 100%;
105105
--icon-size: 1rem;
106-
-webkit-mask-image: url("icons/system/external-link-line.svg");
107-
mask-image: url("icons/system/external-link-line.svg");
106+
-webkit-mask-image: url("../../icons/system/external-link-line.svg");
107+
mask-image: url("../../icons/system/external-link-line.svg");
108108
content: var(--external-link-content);
109109
margin-left: 0.25rem;
110110
}

0 commit comments

Comments
 (0)