From 9a969ac39d0d8eb8fc9c267d9d4950cd9cb52168 Mon Sep 17 00:00:00 2001 From: Mihai Date: Sun, 14 Apr 2024 18:06:17 +0300 Subject: [PATCH] Fix alias path on Windows to be '@/*' or '@src/*' instead of '@\\*' or '@src\\*' (#69) * Fix alias path on Windows, since unlike replacement which is a valid directory path, on Windows using path, the alias string gets escaped to '@\\*' or '@src\\*' instead of '@/*' or '@src/*' * changeset --------- Co-authored-by: Mihai1iMob Co-authored-by: Horus Lugo --- .changeset/fresh-beers-care.md | 5 +++++ packages/vite-plugin-stylex/src/index.mts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/fresh-beers-care.md diff --git a/.changeset/fresh-beers-care.md b/.changeset/fresh-beers-care.md new file mode 100644 index 0000000..6925206 --- /dev/null +++ b/.changeset/fresh-beers-care.md @@ -0,0 +1,5 @@ +--- +"vite-plugin-stylex": patch +--- + +Fix alias path on Windows to be '@/_' or '@src/_' instead of '@\\_' or '@src\\_'. Thanks to @DarkAng3L for the PR! diff --git a/packages/vite-plugin-stylex/src/index.mts b/packages/vite-plugin-stylex/src/index.mts index 9b94bdd..92d257d 100644 --- a/packages/vite-plugin-stylex/src/index.mts +++ b/packages/vite-plugin-stylex/src/index.mts @@ -220,7 +220,7 @@ export default function styleXVitePlugin({ if (typeof viteAlias.find === "string") { // We need to convert Vite format to this plugin's format: // Example: @ -> @/* - const alias = path.join(viteAlias.find, "*"); + const alias = viteAlias.find.concat("/*"); aliases[alias] = [path.join(viteAlias.replacement, "*")]; } }