Skip to content

Commit 681b4bd

Browse files
committed
seems to work
1 parent f9c5275 commit 681b4bd

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

apps/storybook/.storybook/main.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,26 @@ const config: StorybookConfig = {
2525
viteFinal: async (config) => {
2626
const rootDir = fileURLToPath(new URL("../../../", import.meta.url))
2727
config.resolve = config.resolve || {}
28-
config.resolve.alias = {
29-
...(config.resolve.alias || {}),
30-
"@": rootDir,
31-
shared: path.resolve(rootDir, "shared/src"),
32-
"@/shared": path.resolve(rootDir, "shared/src"),
33-
}
28+
29+
// Filter out any existing @ aliases and add our own at the beginning
30+
const existingAliases = Array.isArray(config.resolve.alias)
31+
? config.resolve.alias.filter(
32+
(a) =>
33+
!(
34+
(typeof a.find === "string" && a.find.startsWith("@")) ||
35+
(a.find instanceof RegExp && a.find.source.includes("@"))
36+
)
37+
)
38+
: Object.entries(config.resolve.alias || {})
39+
.filter(([find]) => !find.startsWith("@"))
40+
.map(([find, replacement]) => ({ find, replacement }))
41+
42+
config.resolve.alias = [
43+
{ find: /^@\/shared/, replacement: path.resolve(rootDir, "shared/src") },
44+
{ find: /^shared/, replacement: path.resolve(rootDir, "shared/src") },
45+
{ find: /^@\//, replacement: `${rootDir}/` },
46+
...existingAliases,
47+
]
3448
return config
3549
},
3650
}

apps/storybook/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
"baseUrl": ".",
55
"moduleResolution": "bundler",
66
"paths": {
7-
"@/*": ["../../*"],
87
"@/shared/*": ["../../shared/src/*"],
8+
"@/components/*": ["../../components/*"],
9+
"@/lib/*": ["../../lib/*"],
10+
"@/styles/*": ["../../styles/*"],
911
"@workers/*": ["../workers/src/*"]
1012
}
1113
},

0 commit comments

Comments
 (0)