2021-04-23 20:25:05 +00:00
|
|
|
|
module.exports = {
|
2022-02-18 16:07:09 +00:00
|
|
|
|
stories: [
|
|
|
|
|
'../../client/**/*.stories.mdx',
|
|
|
|
|
'../../client/**/*.stories.@(js|tsx)',
|
|
|
|
|
{
|
|
|
|
|
directory: '../../wagtail/admin/templates/wagtailadmin/shared/',
|
|
|
|
|
titlePrefix: 'Shared',
|
2023-06-15 15:36:46 +00:00
|
|
|
|
files: '**/*.stories.*',
|
2022-02-18 16:07:09 +00:00
|
|
|
|
},
|
|
|
|
|
'../../wagtail/**/*.stories.*',
|
|
|
|
|
],
|
|
|
|
|
addons: ['@storybook/addon-docs', '@storybook/addon-controls'],
|
|
|
|
|
framework: '@storybook/react',
|
2022-02-04 11:57:55 +00:00
|
|
|
|
core: {
|
|
|
|
|
builder: 'webpack5',
|
2021-04-24 08:32:24 +00:00
|
|
|
|
},
|
2023-02-14 11:18:29 +00: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 04:21:23 +00:00
|
|
|
|
webpackFinal: (config) => {
|
2022-02-18 15:34:33 +00:00
|
|
|
|
/* eslint-disable no-param-reassign */
|
2021-12-23 04:21:23 +00:00
|
|
|
|
|
|
|
|
|
const rules = [
|
|
|
|
|
{
|
|
|
|
|
test: /\.(scss|css)$/,
|
|
|
|
|
use: [
|
2022-02-04 11:57:55 +00:00
|
|
|
|
'style-loader',
|
2022-06-08 22:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
loader: 'css-loader',
|
|
|
|
|
options: {
|
|
|
|
|
url: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-12-23 04:21:23 +00:00
|
|
|
|
{
|
2022-02-04 11:57:55 +00:00
|
|
|
|
loader: 'postcss-loader',
|
2021-12-23 04:21:23 +00:00
|
|
|
|
options: {
|
|
|
|
|
postcssOptions: {
|
2022-02-27 16:08:38 +00:00
|
|
|
|
plugins: ['tailwindcss', 'autoprefixer', 'cssnano'],
|
2021-12-23 04:21:23 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-02-04 11:57:55 +00:00
|
|
|
|
'sass-loader',
|
2021-12-23 04:21:23 +00:00
|
|
|
|
],
|
|
|
|
|
},
|
2022-02-18 15:34:33 +00:00
|
|
|
|
{
|
|
|
|
|
test: /\.(md|html)$/,
|
|
|
|
|
type: 'asset/source',
|
|
|
|
|
},
|
2021-12-23 04:21:23 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
config.module.rules = config.module.rules.concat(rules);
|
|
|
|
|
|
2022-02-18 16:07:09 +00:00
|
|
|
|
// Allow using path magic variables to reduce boilerplate in stories.
|
2022-02-18 15:34:33 +00:00
|
|
|
|
config.node = {
|
|
|
|
|
__filename: true,
|
|
|
|
|
__dirname: true,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-24 08:32:24 +00:00
|
|
|
|
return config;
|
|
|
|
|
},
|
2021-12-23 04:21:23 +00:00
|
|
|
|
};
|