-
Notifications
You must be signed in to change notification settings - Fork 14
/
next.config.mjs
104 lines (97 loc) · 2.58 KB
/
next.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import remarkGfm from "remark-gfm";
import path from "path";
import glob from "glob";
import withTMConfig from "next-transpile-modules";
const withTM = withTMConfig([
"@patternfly/react-core",
"@patternfly/react-styles",
"@patternfly/react-icons",
]);
/**
* Function that searches for all patternfly styles in node_modules and outputs an webpack alias object to ignore found modules.
* @param {string} root absolute directory path to root folder containig package.json
* @returns {Object}
*/
const searchIgnoredStyles = (root) => {
const ignoredPaths = [
path.join(root, "./node_modules/@patternfly/react-styles"),
path.join(
root,
"./node_modules/@redhat-cloud-services/frontend-components"
),
];
let result = {};
ignoredPaths.forEach((path) => {
result = {
...result,
...glob.sync(`${path}/**/*.css`).reduce((acc, curr) => {
if (
curr.includes("@redhat-cloud-services/frontend-components/index.css")
) {
return acc;
}
return {
...acc,
[curr]: false,
};
}, {}),
};
});
return result;
};
export default withTM({
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
experimental: {
esmExternals: true,
},
basePath: "/platform-docs",
assetPrefix: "/platform-docs",
async redirects() {
return [
{
source: "/",
destination: "/platform-docs",
basePath: false,
permanent: false,
},
];
},
webpack: (config) => {
config.resolve.alias = {
"@docs/example-component": path.resolve(
process.cwd(),
"./components/example-component"
),
"@docs/components": path.resolve(process.cwd(), "./components"),
"@docs/examples": path.resolve(process.cwd(), "./components/examples"),
"@docs/consoledot-pages": path.resolve(
process.cwd(),
"./components/consoledot-pages"
),
"@docs/parser": path.resolve(process.cwd(), "./components/parser"),
"@docs/deprecation-warn": path.resolve(
process.cwd(),
"./components/deprecation-warn"
),
"@docs/extensive-prop": path.resolve(
process.cwd(),
"./components/extensive-prop"
),
...config.resolve.alias,
...searchIgnoredStyles(process.cwd()),
};
config.module.rules.push({
test: /\.mdx?$/,
use: [
{
loader: "@mdx-js/loader",
options: {
providerImportSource: "@mdx-js/react",
remarkPlugins: [remarkGfm],
},
},
],
});
return config;
},
});