Files
medusa-store/www/apps/api-reference/next.config.mjs
Shahed Nasser d1a1135328 docs: migrate UI docs (#13245)
* docs: create a new UI docs project (#13233)

* docs: create a new UI docs project

* fix installation errors

* docs: migrate UI docs content to new project (#13241)

* Fix content

* added examples for some components

* finish adding examples

* lint fix

* fix build errors

* delete empty files

* path fixes + refactor

* fix build error
2025-08-20 11:42:25 +03:00

107 lines
2.7 KiB
JavaScript

import createMDX from "@next/mdx"
import bundleAnalyzer from "@next/bundle-analyzer"
import rehypeMdxCodeProps from "rehype-mdx-code-props"
import rehypeSlug from "rehype-slug"
import {
brokenLinkCheckerPlugin,
crossProjectLinksPlugin,
} from "remark-rehype-plugins"
import path from "path"
import { catchBadRedirects } from "build-scripts"
/** @type {import('next').NextConfig} */
const nextConfig = {
// Configure `pageExtensions` to include MDX files
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/api",
webpack: (config) => {
config.ignoreWarnings = [{ module: /node_modules\/keyv\/src\/index\.js/ }]
return config
},
transpilePackages: ["docs-ui", "docs-utils"],
experimental: {
optimizePackageImports: ["docs-utils"],
},
async redirects() {
return catchBadRedirects([
{
source: "/api/download/:path",
destination: "/download/:path",
permanent: true,
},
])
},
}
const withMDX = createMDX({
options: {
rehypePlugins: [
[
brokenLinkCheckerPlugin,
{
crossProjects: {
docs: {
projectPath: path.resolve("..", "book"),
},
resources: {
projectPath: path.resolve("..", "resources"),
hasGeneratedSlugs: true,
},
ui: {
projectPath: path.resolve("..", "ui"),
},
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
},
cloud: {
projectPath: path.resolve("..", "cloud"),
},
},
},
],
[
crossProjectLinksPlugin,
{
baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
projectUrls: {
docs: {
url: process.env.NEXT_PUBLIC_DOCS_URL,
path: "",
},
resources: {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
},
"user-guide": {
url: process.env.NEXT_PUBLIC_USER_GUIDE_URL,
},
ui: {
url: process.env.NEXT_PUBLIC_UI_URL,
},
cloud: {
url: process.env.NEXT_PUBLIC_CLOUD_URL,
},
},
useBaseUrl:
process.env.NODE_ENV === "production" ||
process.env.VERCEL_ENV === "production",
},
],
[
rehypeMdxCodeProps,
{
tagName: "code",
},
],
[rehypeSlug],
],
development: process.env.NODE_ENV === "development",
},
})
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE_BUNDLE === "true",
})
export default withMDX(withBundleAnalyzer(nextConfig))