2021-04-23 22:25:05 +02:00
|
|
|
|
module.exports = {
|
2022-02-18 17:07:09 +01:00
|
|
|
|
stories: [
|
|
|
|
|
'../../client/**/*.stories.mdx',
|
|
|
|
|
'../../client/**/*.stories.@(js|tsx)',
|
|
|
|
|
'../../wagtail/**/*.stories.*',
|
|
|
|
|
],
|
2023-12-12 11:54:41 +01:00
|
|
|
|
|
2022-02-18 17:07:09 +01:00
|
|
|
|
addons: ['@storybook/addon-docs', '@storybook/addon-controls'],
|
2023-12-12 11:54:41 +01:00
|
|
|
|
|
|
|
|
|
framework: {
|
|
|
|
|
name: '@storybook/react-webpack5',
|
|
|
|
|
options: {},
|
2021-04-24 10:32:24 +02:00
|
|
|
|
},
|
2023-12-12 11:54:41 +01:00
|
|
|
|
|
2023-02-14 12:18:29 +01:00
|
|
|
|
// Redefine Babel config to allow TypeScript class fields `declare`.
|
|
|
|
|
// See https://github.com/storybookjs/storybook/issues/12479.
|
|
|
|
|
// The resulting configuration is closer to Wagtail’s Webpack + TypeScript setup,
|
|
|
|
|
// preventing other potential issues with JS transpilation differences.
|
|
|
|
|
babel: async (options) => ({
|
|
|
|
|
...options,
|
|
|
|
|
plugins: [],
|
|
|
|
|
presets: [
|
|
|
|
|
['@babel/preset-typescript', { allowDeclareFields: true }],
|
|
|
|
|
['@babel/preset-react', { runtime: 'automatic' }],
|
|
|
|
|
],
|
|
|
|
|
}),
|
2023-12-12 11:54:41 +01:00
|
|
|
|
|
2021-12-23 05:21:23 +01:00
|
|
|
|
webpackFinal: (config) => {
|
2022-02-18 16:34:33 +01:00
|
|
|
|
/* eslint-disable no-param-reassign */
|
2021-12-23 05:21:23 +01:00
|
|
|
|
|
|
|
|
|
const rules = [
|
|
|
|
|
{
|
|
|
|
|
test: /\.(scss|css)$/,
|
|
|
|
|
use: [
|
|
|
|
|
'style-loader',
|
2022-06-09 00:29:38 +02:00
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
url: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-12-23 05:21:23 +01:00
|
|
|
|
{
|
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
|
options: {
|
|
|
|
|
postcssOptions: {
|
2022-02-27 17:08:38 +01:00
|
|
|
|
plugins: ['tailwindcss', 'autoprefixer', 'cssnano'],
|
2021-12-23 05:21:23 +01:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
'sass-loader',
|
|
|
|
|
],
|
|
|
|
|
},
|
2022-02-18 16:34:33 +01:00
|
|
|
|
{
|
|
|
|
|
test: /\.(md|html)$/,
|
|
|
|
|
type: 'asset/source',
|
|
|
|
|
},
|
2021-12-23 05:21:23 +01:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
config.module.rules = config.module.rules.concat(rules);
|
|
|
|
|
|
2022-02-18 17:07:09 +01:00
|
|
|
|
// Allow using path magic variables to reduce boilerplate in stories.
|
2022-02-18 16:34:33 +01:00
|
|
|
|
config.node = {
|
|
|
|
|
__filename: true,
|
|
|
|
|
__dirname: true,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-24 10:32:24 +02:00
|
|
|
|
return config;
|
|
|
|
|
},
|
2023-12-12 11:54:41 +01:00
|
|
|
|
|
|
|
|
|
docs: {
|
|
|
|
|
autodocs: true,
|
|
|
|
|
},
|
2021-12-23 05:21:23 +01:00
|
|
|
|
};
|