2022-04-01 13:44:27 +02:00
|
|
|
const AliasPlugin = require('enhanced-resolve/lib/AliasPlugin');
|
|
|
|
|
2022-02-17 12:30:49 +01:00
|
|
|
module.exports = {
|
2022-02-17 13:41:57 +01:00
|
|
|
stories: [
|
|
|
|
'../src/**/*.stories.mdx',
|
|
|
|
'../src/**/*.stories.@(js|jsx|ts|tsx)',
|
|
|
|
],
|
|
|
|
addons: [
|
|
|
|
'@storybook/addon-links',
|
|
|
|
'@storybook/addon-essentials',
|
|
|
|
'@storybook/addon-interactions',
|
|
|
|
'storybook-addon-root-attribute/register',
|
|
|
|
],
|
|
|
|
framework: '@storybook/react',
|
2022-02-18 08:35:59 +01:00
|
|
|
staticDirs: [
|
|
|
|
{
|
|
|
|
from: '../static',
|
|
|
|
to: '/',
|
|
|
|
},
|
|
|
|
],
|
2022-02-25 12:57:13 +01:00
|
|
|
webpackFinal: async (config) => {
|
2022-02-25 15:37:04 +01:00
|
|
|
const path = require('path');
|
|
|
|
|
2022-04-01 13:44:27 +02:00
|
|
|
const docusaurusPath = (...paths) =>
|
|
|
|
path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'../',
|
|
|
|
'node_modules',
|
|
|
|
'@docusaurus',
|
|
|
|
...paths,
|
|
|
|
);
|
|
|
|
|
|
|
|
config.resolve.plugins = [
|
2022-04-02 16:47:38 +02:00
|
|
|
// add a "layered" approach to theme resolution that matches
|
|
|
|
// Docusaurus' theme resolution:
|
|
|
|
// https://docusaurus.io/docs/2.0.0-beta.17/advanced/client#theme-aliases
|
|
|
|
//
|
|
|
|
// First, check to see if the referenced component has
|
|
|
|
// been swizzled and exists in `../src/theme`.
|
|
|
|
//
|
|
|
|
// If it's not there, check the `theme-classic/lib-next/theme` directory in
|
|
|
|
// `node_modules`.
|
|
|
|
//
|
|
|
|
// Finally, if it's not found anywhere else, check the
|
|
|
|
// `theme-fallback` directory.
|
2022-04-01 13:44:27 +02:00
|
|
|
new AliasPlugin(
|
|
|
|
'described-resolve',
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: '@theme',
|
|
|
|
alias: [
|
|
|
|
path.resolve(__dirname, '../', 'src', 'theme'),
|
|
|
|
docusaurusPath(
|
|
|
|
'theme-classic',
|
|
|
|
'lib-next',
|
|
|
|
'theme',
|
|
|
|
),
|
|
|
|
docusaurusPath(
|
|
|
|
'core',
|
|
|
|
'lib',
|
|
|
|
'client',
|
|
|
|
'theme-fallback',
|
|
|
|
),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'resolve',
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
2022-02-25 15:37:04 +01:00
|
|
|
config.resolve.alias = {
|
|
|
|
...config.resolve.alias,
|
|
|
|
'@site': path.resolve(__dirname, '../'),
|
2022-04-02 16:40:37 +02:00
|
|
|
'@docusaurus/theme-common': docusaurusPath(
|
2022-04-01 13:44:27 +02:00
|
|
|
'theme-common',
|
|
|
|
'src',
|
|
|
|
'index.ts',
|
|
|
|
),
|
2022-04-02 16:40:37 +02:00
|
|
|
'@docusaurus/utils-common': docusaurusPath('utils-common', 'lib'),
|
|
|
|
'@docusaurus/plugin-content-docs': docusaurusPath(
|
2022-04-01 13:44:27 +02:00
|
|
|
'plugin-content-docs',
|
|
|
|
'src',
|
|
|
|
),
|
2022-04-02 16:40:37 +02:00
|
|
|
'@docusaurus': docusaurusPath('core', 'lib', 'client', 'exports'),
|
2022-03-02 10:50:46 +01:00
|
|
|
'@generated': path.resolve(__dirname, '../', '.docusaurus'),
|
2022-02-25 15:37:04 +01:00
|
|
|
};
|
|
|
|
|
2022-02-25 16:38:32 +01:00
|
|
|
let cssRules = [];
|
2022-02-25 15:37:04 +01:00
|
|
|
const rules = config.module.rules.map((rule) => {
|
2022-02-25 16:38:32 +01:00
|
|
|
if (rule.test.toString() === '/\\.css$/') {
|
|
|
|
cssRules.push(JSON.parse(JSON.stringify(rule)));
|
2022-02-25 15:37:04 +01:00
|
|
|
|
|
|
|
return {
|
2022-02-25 16:38:32 +01:00
|
|
|
...rule,
|
|
|
|
exclude: /\.module\.css$/,
|
2022-02-25 15:37:04 +01:00
|
|
|
};
|
2022-04-01 13:44:27 +02:00
|
|
|
} else if (rule.test.toString() === '/\\.(mjs|tsx?|jsx?)$/') {
|
|
|
|
return {
|
|
|
|
...rule,
|
|
|
|
// don't exclude docusaurus files
|
|
|
|
exclude: /node_modules\/(?!@docusaurus)/,
|
|
|
|
};
|
2022-02-25 16:38:32 +01:00
|
|
|
} else return rule;
|
|
|
|
});
|
2022-02-25 15:37:04 +01:00
|
|
|
|
2022-02-25 16:38:32 +01:00
|
|
|
cssRules.forEach((r) => {
|
|
|
|
const moduleRule = {
|
|
|
|
...r,
|
|
|
|
test: /\.module\.css$/,
|
|
|
|
use: r.use.map((use) => {
|
|
|
|
if (
|
|
|
|
typeof use === 'object' &&
|
|
|
|
use.loader.includes('/css-loader/')
|
|
|
|
) {
|
|
|
|
use.options = {
|
|
|
|
...use.options,
|
|
|
|
modules: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return use;
|
|
|
|
}),
|
2022-02-25 15:37:04 +01:00
|
|
|
};
|
2022-02-25 16:38:32 +01:00
|
|
|
rules.push(moduleRule);
|
2022-02-25 15:37:04 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
...config,
|
|
|
|
module: {
|
|
|
|
...config.module,
|
|
|
|
rules,
|
|
|
|
},
|
|
|
|
};
|
2022-02-25 12:57:13 +01:00
|
|
|
},
|
2022-02-17 13:41:57 +01:00
|
|
|
};
|