-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmain.ts
More file actions
91 lines (83 loc) · 2.82 KB
/
main.ts
File metadata and controls
91 lines (83 loc) · 2.82 KB
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
// This file has been automatically migrated to valid ESM format by Storybook.
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
import type { StorybookConfig } from '@storybook/react-webpack5';
import { resolve, dirname, join } from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const require = createRequire(import.meta.url);
const config: StorybookConfig = {
stories: [
'../src/lib/**/*.@(mdx)',
'../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)',
],
staticDirs: ['../src/static'],
addons: [
getAbsolutePath('@storybook/addon-webpack5-compiler-babel'),
// the @nx/react storybook plugin is just a subdirectory of the @nx/react package
// so getting the absolute path of the package.json won't work. they do expose
// a require export though, so we can just use that directly
require.resolve('@nx/react/plugins/storybook'),
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-docs'),
getAbsolutePath('@storybook/addon-a11y'),
getAbsolutePath('@storybook/addon-designs'),
getAbsolutePath('storybook-addon-deep-controls'),
],
framework: {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {
builder: {},
},
},
docs: {},
typescript: {
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
skipChildrenPropWithoutDoc: false,
shouldRemoveUndefinedFromOptional: true,
propFilter: (prop) => {
if (prop.parent && /node_modules/.test(prop.parent.fileName)) {
return false;
}
if (['mode', 'theme'].includes(prop.name)) {
return false;
}
return true;
},
},
},
webpackFinal(config) {
config.resolve = {
...config.resolve,
alias: {
...config.resolve?.alias,
'~styleguide/blocks': resolve(__dirname, './components/'),
'~styleguide/argTypes': resolve(__dirname, './argTypes/'),
'@codecademy/gamut-styles$': resolve(
__dirname,
'../../gamut-styles/src'
),
'@codecademy/gamut$': resolve(__dirname, '../../gamut/src'),
'@codecademy/gamut-illustrations$': resolve(
__dirname,
'../../gamut-illustrations/src'
),
'@codecademy/gamut-icons$': resolve(__dirname, '../../gamut-icons/src'),
'@codecademy/gamut-patterns$': resolve(
__dirname,
'../../gamut-patterns/src'
),
'@codecademy/variance$': resolve(__dirname, '../../variance/src'),
},
};
config.infrastructureLogging = {
level: 'warn',
};
return config;
},
};
export default config;
function getAbsolutePath(value: string, root = 'package.json'): string {
return dirname(require.resolve(join(value, root)));
}