2023-06-04 12:23:09 +03:00
|
|
|
const path = require('path');
|
|
|
|
|
2023-09-19 05:07:38 +03:00
|
|
|
computeStoriesGlob = () => {
|
2023-10-16 23:06:07 +03:00
|
|
|
if (process.env.STORYBOOK_SCOPE === 'pages') {
|
2023-10-08 14:21:54 +03:00
|
|
|
return [
|
|
|
|
'../src/pages/**/*.stories.@(js|jsx|ts|tsx)',
|
|
|
|
'../src/__stories__/*.stories.@(js|jsx|ts|tsx)',
|
|
|
|
'../src/pages/**/*.docs.mdx',
|
|
|
|
'../src/__stories__/*.docs.mdx'
|
|
|
|
]
|
2023-09-19 05:07:38 +03:00
|
|
|
}
|
|
|
|
|
2023-10-16 23:06:07 +03:00
|
|
|
if (process.env.STORYBOOK_SCOPE === 'modules') {
|
2023-10-08 14:21:54 +03:00
|
|
|
return ['../src/modules/**/*.stories.@(js|jsx|ts|tsx)', '../src/modules/**/*.docs.mdx']
|
2023-09-19 05:07:38 +03:00
|
|
|
}
|
|
|
|
|
2023-10-16 23:06:07 +03:00
|
|
|
if (process.env.STORYBOOK_SCOPE === 'ui-docs') {
|
|
|
|
return ['../src/modules/ui/**/*.docs.mdx'];
|
|
|
|
}
|
|
|
|
|
2023-10-08 14:21:54 +03:00
|
|
|
return ['../src/**/*.stories.@(js|jsx|ts|tsx)', '../src/**/*.docs.mdx']
|
2023-09-19 05:07:38 +03:00
|
|
|
};
|
|
|
|
|
2022-12-05 00:59:30 +03:00
|
|
|
module.exports = {
|
2023-07-24 21:06:37 +03:00
|
|
|
webpackFinal: (config) => {
|
2022-12-05 00:59:30 +03:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2023-07-24 21:06:37 +03:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: require.resolve('babel-loader'),
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
require('@babel/preset-typescript').default,
|
|
|
|
[
|
|
|
|
require('@babel/preset-react').default,
|
|
|
|
{
|
|
|
|
runtime: 'automatic',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
require('@babel/preset-env').default,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2023-04-11 00:31:55 +03:00
|
|
|
});
|
|
|
|
config.resolve.extensions.push('.ts', '.tsx');
|
2022-12-05 00:59:30 +03:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.mjs$/,
|
|
|
|
include: /node_modules/,
|
2023-07-24 21:06:37 +03:00
|
|
|
type: 'javascript/auto',
|
2023-04-11 00:31:55 +03:00
|
|
|
});
|
2023-06-19 17:07:16 +03:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
{
|
2023-07-24 21:06:37 +03:00
|
|
|
loader: '@svgr/webpack',
|
2023-06-19 17:07:16 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2023-07-24 21:06:37 +03:00
|
|
|
name: 'static/media/[path][name].[ext]',
|
|
|
|
},
|
|
|
|
},
|
2023-06-19 17:07:16 +03:00
|
|
|
],
|
|
|
|
type: 'javascript/auto',
|
|
|
|
issuer: {
|
2023-07-24 21:06:37 +03:00
|
|
|
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
|
|
},
|
2023-06-19 17:07:16 +03:00
|
|
|
});
|
2023-04-11 00:31:55 +03:00
|
|
|
config.resolve.extensions.push('.mjs');
|
2023-06-04 12:23:09 +03:00
|
|
|
config.resolve.alias = {
|
|
|
|
...config.resolve.alias,
|
2023-07-24 21:06:37 +03:00
|
|
|
'~': path.resolve(__dirname, '../src'),
|
|
|
|
'@': path.resolve(__dirname, '../src/modules'),
|
2023-06-04 12:23:09 +03:00
|
|
|
};
|
2023-04-11 00:31:55 +03:00
|
|
|
return config;
|
2022-12-05 00:59:30 +03:00
|
|
|
},
|
2023-09-19 05:07:38 +03:00
|
|
|
stories: computeStoriesGlob(),
|
2023-05-29 12:02:38 +03:00
|
|
|
addons: [
|
2023-07-24 21:06:37 +03:00
|
|
|
'@storybook/addon-links',
|
|
|
|
'@storybook/addon-essentials',
|
|
|
|
'@storybook/addon-interactions',
|
|
|
|
'@storybook/addon-coverage',
|
|
|
|
'@storybook/addon-styling',
|
|
|
|
'storybook-addon-pseudo-states',
|
|
|
|
'storybook-addon-cookie',
|
2023-05-29 12:02:38 +03:00
|
|
|
],
|
2023-10-08 14:21:54 +03:00
|
|
|
docs: { autodocs: false },
|
2023-04-11 00:31:55 +03:00
|
|
|
framework: {
|
|
|
|
name: '@storybook/react-webpack5',
|
2023-07-24 21:06:37 +03:00
|
|
|
options: {},
|
2023-04-11 00:31:55 +03:00
|
|
|
},
|
2023-07-24 21:06:37 +03:00
|
|
|
};
|