diff --git a/next.config.ts b/next.config.ts index 56fb66502edf1b..400891e6df29e5 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,27 +1,86 @@ -import {codecovNextJSWebpackPlugin} from '@codecov/nextjs-webpack-plugin'; -import {withSentryConfig} from '@sentry/nextjs'; +import { codecovNextJSWebpackPlugin } from '@codecov/nextjs-webpack-plugin'; +import { withSentryConfig } from '@sentry/nextjs'; -import {redirects} from './redirects.js'; +import { redirects } from './redirects.js'; const outputFileTracingExcludes = process.env.NEXT_PUBLIC_DEVELOPER_DOCS ? { - '/**/*': ['./.git/**/*', './apps/**/*', 'docs/**/*'], - } + '/**/*': [ + './.git/**/*', + './apps/**/*', + 'docs/**/*', + // Add image exclusions for dev docs too + 'public/mdx-images/**/*', + '**/*.png', + '**/*.jpg', + '**/*.jpeg', + '**/*.gif', + '**/*.svg', + '**/*.webp', + '**/*.pdf' + ], + } : { - '/**/*': [ - './.git/**/*', - './apps/**/*', - 'develop-docs/**/*', - 'node_modules/@esbuild/darwin-arm64', - ], - '/platform-redirect': ['**/*.gif', 'public/mdx-images/**/*', '*.pdf'], - '\\[\\[\\.\\.\\.path\\]\\]': [ - 'docs/**/*', - 'node_modules/prettier/plugins', - 'node_modules/rollup/dist', - ], - 'sitemap.xml': ['docs/**/*', 'public/mdx-images/**/*', '*.gif', '*.pdf', '*.png'], - }; + '/**/*': [ + './.git/**/*', + './apps/**/*', + 'develop-docs/**/*', + 'node_modules/@esbuild/darwin-arm64', + // CRITICAL: Add comprehensive image exclusions globally + 'public/mdx-images/**/*', + 'public/**/*.png', + 'public/**/*.jpg', + 'public/**/*.jpeg', + 'public/**/*.gif', + 'public/**/*.svg', + 'public/**/*.webp', + 'public/**/*.pdf', + // Exclude large dependencies that shouldn't be in functions + 'node_modules/@google-cloud/**/*', + 'node_modules/@aws-sdk/**/*', + 'node_modules/sharp/**/*', + 'node_modules/mermaid/**/*', + ], + '/platform-redirect': ['**/*.gif', 'public/mdx-images/**/*', '*.pdf'], + '/[[...path]]': [ + 'docs/**/*', + 'node_modules/prettier/plugins', + 'node_modules/rollup/dist', + // CRITICAL: Add image exclusions for main docs route + 'public/mdx-images/**/*', + '**/*.gif', + '**/*.png', + '**/*.jpg', + '**/*.jpeg', + '**/*.pdf', + '**/*.svg', + '**/*.webp', + // Exclude heavy deps from main route + 'node_modules/@google-cloud/**/*', + 'node_modules/@aws-sdk/**/*', + 'node_modules/sharp/**/*', + 'node_modules/mermaid/**/*', + ], + // Fallback pattern in case Next.js uses different internal naming + '[[...path]]': [ + 'docs/**/*', + 'public/mdx-images/**/*', + '**/*.gif', + '**/*.png', + '**/*.jpg', + '**/*.jpeg', + '**/*.pdf', + '**/*.svg', + '**/*.webp', + 'node_modules/prettier/plugins', + 'node_modules/rollup/dist', + 'node_modules/@google-cloud/**/*', + 'node_modules/@aws-sdk/**/*', + 'node_modules/sharp/**/*', + 'node_modules/mermaid/**/*', + ], + 'sitemap.xml': ['docs/**/*', 'public/mdx-images/**/*', '*.gif', '*.pdf', '*.png', '**/*.jpg', '**/*.jpeg'], + }; if ( process.env.NODE_ENV !== 'development' && diff --git a/src/components/docImage.tsx b/src/components/docImage.tsx index cef75042244cee..d7c07b0bea19bf 100644 --- a/src/components/docImage.tsx +++ b/src/components/docImage.tsx @@ -1,7 +1,6 @@ -import path from 'path'; - -import Image from 'next/image'; +// import path from 'path'; +// import Image from 'next/image'; import {serverContext} from 'sentry-docs/serverContext'; export default function DocImage({ @@ -24,7 +23,7 @@ export default function DocImage({ // If the image src is not an absolute URL, we assume it's a relative path // and we prepend /mdx-images/ to it. if (src.startsWith('./')) { - src = path.join('/mdx-images', src); + src = '/mdx-images/' + src.slice(2); // Remove './' and prepend '/mdx-images/' } // account for the old way of doing things where the public folder structure mirrored the docs folder else if (!src?.startsWith('/') && !src?.includes('://')) { @@ -34,6 +33,9 @@ export default function DocImage({ // parse the size from the URL hash (set by remark-image-size.js) const srcURL = new URL(src, 'https://example.com'); const imgPath = srcURL.pathname; + + // Debug: log the final URL (remove this after testing) + console.log('DocImage - Final src:', src, 'imgPath:', imgPath); const [width, height] = srcURL.hash // #wxh .slice(1) .split('x') @@ -41,7 +43,7 @@ export default function DocImage({ return ( -