Skip to content

Commit 6540dfe

Browse files
committed
fix storybook public fonts
- fixed the storybook issue with not picking up absolute paths by using a webpack config specifically in the storybook config (so it doesnt affect/change the library itself)
1 parent 880f202 commit 6540dfe

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.storybook/main.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { StorybookConfig } from "@storybook/react-webpack5";
2+
import path from "path";
3+
24
const config: StorybookConfig = {
35
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
46
staticDirs: ["../public"],
@@ -22,5 +24,23 @@ const config: StorybookConfig = {
2224
docs: {
2325
autodocs: "tag",
2426
},
27+
webpackFinal: async (config) => {
28+
if (config.resolve) {
29+
config.resolve = {
30+
...config.resolve,
31+
alias: {
32+
...config.resolve.alias,
33+
"/fonts": path.resolve(__dirname, "../public/fonts"),
34+
},
35+
};
36+
} else {
37+
config.resolve = {
38+
alias: {
39+
"/fonts": path.resolve(__dirname, "../public/fonts"),
40+
},
41+
};
42+
}
43+
return config;
44+
},
2545
};
2646
export default config;

0 commit comments

Comments
 (0)