-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathmain.ts
104 lines (97 loc) · 2.77 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"
import { propNames } from "@chakra-ui/react"
import type { StorybookConfig } from "@storybook/nextjs"
/**
* Note regarding package.json settings related to Storybook:
*
* There is a resolutions option set for the package `jackspeak`. This is related to a
* workaround provided to make sure storybook ( as of v7.5.2) works correctly with
* Yarn v1
*
* Reference: https://github.com/storybookjs/storybook/issues/22431#issuecomment-1630086092
*
* The primary recommendation is to upgrade to Yarn 3 if possible
*/
const config: StorybookConfig = {
stories: [
"../src/components/**/*.stories.{ts,tsx}",
"../src/@chakra-ui/stories/*.stories.tsx",
"../src/layouts/stories/*.stories.tsx",
],
addons: [
"@storybook/addon-links",
{
name: "@storybook/addon-essentials",
options: {
backgrounds: false,
},
},
"@storybook/addon-interactions",
"storybook-react-i18next",
"@storybook/addon-themes",
"@chromatic-com/storybook",
],
staticDirs: ["../public"],
framework: {
name: "@storybook/nextjs",
options: {},
},
docs: {
autodocs: "tag",
},
refs: {
"@chakra-ui/react": {
disable: true,
},
},
webpackFinal: async (config) => {
config.module = config.module || {}
config.module.rules = config.module.rules || []
if (config.resolve) {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: config.resolve.extensions,
}),
]
}
// This modifies the existing image rule to exclude .svg files
// since you want to handle those files with @svgr/webpack
const imageRule = config.module.rules.find((rule) =>
rule?.["test"]?.test(".svg")
)
if (imageRule) {
imageRule["exclude"] = /\.svg$/
}
// Configure .svg files to be loaded with @svgr/webpack
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
})
return config
},
typescript: {
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
/**
* For handling bloated controls table of Chakra Props
*
* https://github.com/chakra-ui/chakra-ui/issues/2009#issuecomment-852793946
*/
propFilter: (prop) => {
const excludedPropNames = propNames.concat([
"as",
"apply",
"sx",
"__css",
])
const isStyledSystemProp = excludedPropNames.includes(prop.name)
const isHTMLElementProp =
prop.parent?.fileName.includes("node_modules") ?? false
return !(isStyledSystemProp || isHTMLElementProp)
},
},
reactDocgen: "react-docgen-typescript",
},
}
export default config