Fix
This commit is contained in:
+30
-2
@@ -1,10 +1,38 @@
|
|||||||
import { createMDX } from 'fumadocs-mdx/next';
|
import { createMDX } from 'fumadocs-mdx/next';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const withMDX = createMDX();
|
const withMDX = createMDX();
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
|
||||||
const config = {
|
const config = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withMDX(config);
|
const nextConfig = withMDX(config);
|
||||||
|
|
||||||
|
const mdxLoaderPath = path.resolve(__dirname, 'loaders/fumadocs-mdx-loader.cjs');
|
||||||
|
const metaLoaderPath = path.resolve(__dirname, 'loaders/fumadocs-meta-loader.cjs');
|
||||||
|
|
||||||
|
if (nextConfig.turbopack?.rules) {
|
||||||
|
for (const rule of Object.values(nextConfig.turbopack.rules)) {
|
||||||
|
if (rule.loaders) {
|
||||||
|
for (const l of rule.loaders) {
|
||||||
|
if (l.loader === 'fumadocs-mdx/webpack/mdx') l.loader = mdxLoaderPath;
|
||||||
|
if (l.loader === 'fumadocs-mdx/webpack/meta') l.loader = metaLoaderPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const origWebpack = nextConfig.webpack;
|
||||||
|
nextConfig.webpack = (config, options) => {
|
||||||
|
config.resolveLoader ??= {};
|
||||||
|
config.resolveLoader.alias ??= {};
|
||||||
|
config.resolveLoader.alias['fumadocs-mdx/webpack/mdx'] = mdxLoaderPath;
|
||||||
|
config.resolveLoader.alias['fumadocs-mdx/webpack/meta'] = metaLoaderPath;
|
||||||
|
return origWebpack?.(config, options) ?? config;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user