-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.ts
58 lines (56 loc) · 1.71 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import type { StorybookConfig } from "@storybook/react-webpack5";
import path, { join, dirname } from "path";
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
}
const config: StorybookConfig = {
stories: [
"../client/src/**/*.mdx",
"../client/src/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
getAbsolutePath("@storybook/addon-webpack5-compiler-swc"),
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@chromatic-com/storybook"),
getAbsolutePath("@storybook/addon-interactions"),
],
framework: {
name: getAbsolutePath("@storybook/react-webpack5"),
options: {},
},
staticDirs: ["../public", "../client/public", "../client/src/app/images"],
typescript: {
reactDocgen: "react-docgen-typescript",
reactDocgenTypescriptOptions: {
compilerOptions: {
allowSyntheticDefaultImports: false,
esModuleInterop: false,
},
},
},
webpackFinal: async (config) => {
if (config.resolve) {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
configFile: path.resolve(__dirname, "../client/tsconfig.json"),
extensions: config.resolve.extensions,
}),
];
}
if (config.module) {
config.module.rules?.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
}
return config;
},
};
export default config;