Skip to content

Commit

Permalink
chore: add more docusaurus alias resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Apr 1, 2022
1 parent 3440b4f commit 0321765
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
71 changes: 71 additions & 0 deletions website/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const AliasPlugin = require('enhanced-resolve/lib/AliasPlugin');

module.exports = {
stories: [
'../src/**/*.stories.mdx',
Expand All @@ -19,9 +21,72 @@ module.exports = {
webpackFinal: async (config) => {
const path = require('path');

const docusaurusPath = (...paths) =>
path.resolve(
__dirname,
'../',
'node_modules',
'@docusaurus',
...paths,
);

config.resolve.plugins = [
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',
),
];

// const docusaurusAliases = await loadDocusaurusAliases();
// console.log(docusaurusAliases);

config.resolve.alias = {
...config.resolve.alias,
'@site': path.resolve(__dirname, '../'),
'@docusaurus/theme-common': path.resolve(
__dirname,
'../',
'node_modules',
'@docusaurus',
'theme-common',
'src',
'index.ts',
),
'@docusaurus/utils-common': path.resolve(
__dirname,
'../',
'node_modules',
'@docusaurus',
'utils-common',
'lib',
),
'@docusaurus/plugin-content-docs': path.resolve(
__dirname,
'../',
'node_modules',
'@docusaurus',
'plugin-content-docs',
'src',
),
'@docusaurus': path.resolve(
__dirname,
'../',
Expand All @@ -44,6 +109,12 @@ module.exports = {
...rule,
exclude: /\.module\.css$/,
};
} else if (rule.test.toString() === '/\\.(mjs|tsx?|jsx?)$/') {
return {
...rule,
// don't exclude docusaurus files
exclude: /node_modules\/(?!@docusaurus)/,
};
} else return rule;
});

Expand Down
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@storybook/testing-library": "^0.0.9",
"@tsconfig/docusaurus": "^1.0.4",
"babel-loader": "^8.2.3",
"enhanced-resolve": "^5.9.2",
"storybook-addon-root-attribute": "^1.0.2",
"typescript": "^4.6.2"
}
Expand Down

0 comments on commit 0321765

Please sign in to comment.