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; } }