Skip to content

Commit 2999279

Browse files
committed
fix: storybook
1 parent ca03763 commit 2999279

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.storybook/main.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { StorybookConfig } from "@storybook/react-vite";
2+
import { fileURLToPath, URL } from "url";
23

3-
import { join, dirname } from "path";
4+
import { join, dirname, resolve } from "path";
45

56
/**
67
* This function is used to resolve the absolute path of a package.
@@ -10,7 +11,7 @@ function getAbsolutePath(value: string) {
1011
return dirname(require.resolve(join(value, "package.json")));
1112
}
1213
const config: StorybookConfig = {
13-
stories: ["./src/stories/**/*.mdx", "./src/**/*.stories.@(ts|tsx)"],
14+
stories: ["../src/stories/**/*.mdx", "../src/**/*.stories.@(ts|tsx)"],
1415
addons: [
1516
getAbsolutePath("@storybook/addon-essentials"),
1617
getAbsolutePath("@storybook/addon-themes"),
@@ -26,5 +27,17 @@ const config: StorybookConfig = {
2627
previewHead: process.env.SNAPSHOT
2728
? (head) => `${head}<style>*{animation:none!important;}</style>`
2829
: undefined,
30+
31+
async viteFinal(config, { configType }) {
32+
const { mergeConfig } = await import('vite');
33+
34+
return mergeConfig(config, {
35+
resolve: {
36+
alias: {
37+
"@": fileURLToPath(new URL(resolve(__dirname, "../src/"), import.meta.url)),
38+
}
39+
}
40+
})
41+
},
2942
};
3043
export default config;

0 commit comments

Comments
 (0)