/
main.js
82 lines (76 loc) · 2.78 KB
/
main.js
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
const DirectoryNamedWebpackPlugin = require('directory-named-webpack-plugin');
const path = require('path');
module.exports = {
stories: ['../packages/**/*.stories.mdx', '../packages/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-a11y',
'@storybook/addon-actions',
'@storybook/addon-viewport',
'storybook-addon-gatsby',
'./addons/google-analytics/register',
],
typescript: {
// enable type checking
check: true,
checkOptions: {
typescript: {
configFile: 'tsconfig.json',
configOverwrite: {
compilerOptions: {isolatedModules: false},
exclude: [
'node_modules',
'docs',
'dist',
'lib',
'bin',
'public',
'.cache',
'.jest-cache',
'.next',
'.yarn',
'cjs',
'esm',
'**/__testfixtures__/**/*',
'**/__fixtures__/**/*',
'packages/paste-nextjs-template/**/*',
'packages/paste-website/**/*',
'packages/paste-cra-template/template/**/*',
'packages/paste-token-contrast-checker/**/*',
'**/__tests__/**',
],
},
},
},
// choose react-docgen-typescript to generate the prop tables
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
// don't include node_module props as you'll cause the machine to run out of memory on our repo
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
},
},
core: {
builder: 'webpack5',
},
webpackFinal: async (config) => {
const customPlugins = [
new DirectoryNamedWebpackPlugin({honorPackage: ['main:dev', 'main'], exclude: /node_modules/}),
];
config.resolve.plugins =
config.resolve.plugins == null ? customPlugins : [...config.resolve.plugins, ...customPlugins];
// Need to custom alias react-dom and scheduler for component profiling in production
// mode. Without doing so, no React profiling data can be extracted from stories
// When they are deployed.
const customAlias = {
'react-dom': path.resolve(__dirname, '../node_modules/react-dom/profiling'),
'scheduler/tracing': 'scheduler/tracing-profiling',
'@emotion/core': path.resolve(__dirname, '../node_modules/@emotion/react'),
'@emotion/styled': path.resolve(__dirname, '../node_modules/@emotion/styled'),
'emotion-theming': path.resolve(__dirname, '../node_modules/@emotion/react'),
};
config.resolve.alias = config.resolve.alias == null ? customAlias : {...config.resolve.alias, ...customAlias};
return config;
},
};