1 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
2 const { getJsLoader } = require('@proton/pack/webpack/js.loader');
3 const getCssLoaders = require('@proton/pack/webpack/css.loader');
4 const getAssetsLoaders = require('@proton/pack/webpack/assets.loader');
5 const getOptimization = require('@proton/pack/webpack/optimization');
12 '../src/stories/**/*.stories.@(mdx|js|jsx|ts|tsx)',
13 '../../../packages/atoms/**/*.stories.@(js|jsx|ts|tsx)',
15 addons: ['@storybook/addon-links', '@storybook/addon-storysource', '@storybook/addon-essentials'],
16 staticDirs: ['../src/assets', '../src/assets/favicons'],
20 reactDocgen: 'react-docgen-typescript',
21 reactDocgenTypescriptOptions: {
22 shouldRemoveUndefinedFromOptional: true,
23 propFilter: (property) => {
24 if (property.parent) {
26 * Only generate docs for properties which are not a part of the @types
27 * package. That way we don't get all the inherited dom attributes for
28 * example from "React.FC<React.HTMLAttributes<HTMLDivElement>>".
30 * Usually examples covered in Storybook docs as well as react-docgen-typescript
31 * itself show a different code-snippet to deal with this, one which ignores
32 * solely based on "node_modules".
34 * Since we're defining the components used in our storybook outside this codebase
35 * and importing it through node_modules, that won't do for us, we need to be
38 return !property.parent.fileName.includes('/node_modules/@types/');
45 webpackFinal: async (config, { configType }) => {
46 const isProduction = configType === 'PRODUCTION';
50 hasReactRefresh: false,
54 const optimization = getOptimization(options);
61 ...config.resolve.fallback,
62 // For some reason storybook brings in openpgp as a dependency and we need to
63 // explicitly disable these in the webpack config
71 ...config.module.rules.filter((rule) => {
72 return rule.test.toString().includes('mdx');
75 test: /\.stories\.(tsx|mdx)?$/,
78 loader: require.resolve('@storybook/source-loader'),
79 options: { parser: 'typescript' },
84 ...[getJsLoader(options), ...getCssLoaders(options), ...getAssetsLoaders(options)],
88 ...config.optimization,
89 minimizer: optimization.minimizer,
91 experiments: { ...config.experiments, asyncWebAssembly: true },
94 new MiniCssExtractPlugin({
95 filename: isProduction ? '[name].[contenthash:8].css' : '[name].css',
96 chunkFilename: isProduction ? '[id].[contenthash:8].css' : '[id].css',