From c9399b853580b6634a3cfff1fbe75c60e33b01b2 Mon Sep 17 00:00:00 2001 From: az33zy <10743275+az33zy@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:52:31 +0500 Subject: [PATCH] fix: path alias resolving --- .changeset/pretty-points-drop.md | 5 +++++ src/store/Store.ts | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .changeset/pretty-points-drop.md diff --git a/.changeset/pretty-points-drop.md b/.changeset/pretty-points-drop.md new file mode 100644 index 0000000..d395cb3 --- /dev/null +++ b/.changeset/pretty-points-drop.md @@ -0,0 +1,5 @@ +--- +"react-ts-css": patch +--- + +Fix path alias resolving diff --git a/src/store/Store.ts b/src/store/Store.ts index 1451a87..f05af8b 100644 --- a/src/store/Store.ts +++ b/src/store/Store.ts @@ -221,13 +221,10 @@ export class Store { const paths = config.compilerOptions.paths; if (activeFileDir.includes(config.baseDir)) { let aliasPath = undefined; - const match = alias.match(/^@\w+/g); - const a = match?.[0]; for (const [key, val] of Object.entries(paths ?? {})) { - const b = key.match(/^@\w+/g)?.[0]; - if (b === a && !!b && !!a) { - const rest = alias.substring(a?.length); - aliasPath = path.join(val[0].replace("*", ""), rest); + const prefix = key.replace("*", ""); + if (alias.startsWith(prefix)) { + aliasPath = alias.replace(prefix, val[0].replace("*", "")); break; } }