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)',
|
|
|
|
|
{
|
|
|
|
|
directory: '../../wagtail/admin/templates/wagtailadmin/shared/',
|
|
|
|
|
titlePrefix: 'Shared',
|
2023-06-15 17:36:46 +02:00
|
|
|
|
files: '**/*.stories.*',
|
2022-02-18 17:07:09 +01:00
|
|
|
|
},
|
|
|
|
|
'../../wagtail/**/*.stories.*',
|
|
|
|
|
],
|
|
|
|
|
addons: ['@storybook/addon-docs', '@storybook/addon-controls'],
|
|
|
|
|
framework: '@storybook/react',
|
2022-02-04 12:57:55 +01:00
|
|
|
|
core: {
|
|
|
|
|
builder: 'webpack5',
|
2021-04-24 10:32:24 +02: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' }],
|
|
|
|
|
],
|
|
|
|
|
}),
|
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: [
|
2022-02-04 12:57:55 +01:00
|
|
|
|
'style-loader',
|
2022-06-09 00:29:38 +02:00
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
url: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-12-23 05:21:23 +01:00
|
|
|
|
{
|
2022-02-04 12:57:55 +01:00
|
|
|
|
loader: 'postcss-loader',
|
2021-12-23 05:21:23 +01:00
|
|
|
|
options: {
|
|
|
|
|
postcssOptions: {
|
2022-02-27 17:08:38 +01:00
|
|
|
|
plugins: ['tailwindcss', 'autoprefixer', 'cssnano'],
|
2021-12-23 05:21:23 +01:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-02-04 12:57:55 +01:00
|
|
|
|
'sass-loader',
|
2021-12-23 05:21:23 +01:00
|
|
|
|
],
|
|
|
|
|
},
|
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;
|
|
|
|
|
},
|
2021-12-23 05:21:23 +01:00
|
|
|
|
};
|