diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60a57fd49d0273..c29c80d7ee367b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -238,7 +238,7 @@ Clicking on **Details** will show you the differences. #### deploy/netlify This renders a preview of the docs with your changes if it succeeds. -Otherwise `pnpm docs:build` or `pnpm docs:export` usually fail locally as well. +Otherwise `pnpm docs:build` usually fails locally as well. #### codecov/project diff --git a/docs/next.config.mjs b/docs/next.config.mjs index 55248cc2e94c07..3003172d42ea77 100644 --- a/docs/next.config.mjs +++ b/docs/next.config.mjs @@ -174,6 +174,7 @@ export default withDocsInfra({ ? `Basic ${Buffer.from(process.env.GITHUB_AUTH).toString('base64')}` : '', }, + distDir: 'export', // Next.js provides a `defaultPathMap` argument, we could simplify the logic. // However, we don't in order to prevent any regression in the `findPages()` method. // @ts-ignore @@ -232,13 +233,20 @@ export default withDocsInfra({ return map; }, - // rewrites has no effect when run `next export` for production - rewrites: async () => { - return [ - { source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' }, - // Make sure to include the trailing slash if `trailingSlash` option is set - { source: '/api/:rest*/', destination: '/api-docs/:rest*/' }, - { source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' }, - ]; - }, + // Used to signal we run yarn build + ...(process.env.NODE_ENV === 'production' + ? { + output: 'export', + } + : { + // rewrites has no effect when run `next export` for production + rewrites: async () => { + return [ + { source: `/:lang(${LANGUAGES.join('|')})?/:rest*`, destination: '/:rest*' }, + // Make sure to include the trailing slash if `trailingSlash` option is set + { source: '/api/:rest*/', destination: '/api-docs/:rest*/' }, + { source: `/static/x/:rest*`, destination: 'http://0.0.0.0:3001/static/x/:rest*' }, + ]; + }, + }), }); diff --git a/docs/package.json b/docs/package.json index 24a5e6e1342895..acf7e7df83f350 100644 --- a/docs/package.json +++ b/docs/package.json @@ -5,12 +5,11 @@ "author": "MUI Team", "license": "MIT", "scripts": { - "build": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile", + "build": "rimraf docs/export && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 next build --profile && pnpm build-sw", "build:clean": "rimraf .next && pnpm build", "build-sw": "node ./scripts/buildServiceWorker.js", "dev": "next dev", "deploy": "git push -f material-ui-docs master:latest", - "export": "rimraf docs/export && next export --threads=3 -o export && pnpm build-sw", "icons": "rimraf --glob public/static/icons/* && node ./scripts/buildIcons.js", "start": "next start", "create-playground": "cpy --cwd=scripts playground.template.tsx ../../pages/playground --rename=index.tsx", @@ -84,7 +83,7 @@ "lz-string": "^1.5.0", "markdown-to-jsx": "^7.4.1", "material-ui-popup-state": "^5.0.10", - "next": "13.5.1", + "next": "^13.5.1", "notistack": "3.0.1", "nprogress": "^0.2.0", "postcss": "^8.4.33", diff --git a/netlify.toml b/netlify.toml index 2328098efcbe53..6745d8863ce9d4 100644 --- a/netlify.toml +++ b/netlify.toml @@ -5,7 +5,7 @@ publish = "docs/export/" # Default build command. - command = "pnpm docs:build && pnpm docs:export" + command = "pnpm docs:build" [build.environment] NODE_VERSION = "18" diff --git a/package.json b/package.json index 0c5fdd82c6ce64..92635d84dac9f0 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "docs:build-color-preview": "babel-node scripts/buildColorTypes", "docs:deploy": "pnpm --filter docs run deploy", "docs:dev": "pnpm --filter docs dev", - "docs:export": "pnpm --filter docs export", "docs:icons": "pnpm --filter docs icons", "docs:size-why": "cross-env DOCS_STATS_ENABLED=true pnpm docs:build", "docs:start": "pnpm --filter docs start", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f17d8a145db7f6..04e11d49f7c4fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -737,7 +737,7 @@ importers: specifier: ^5.0.10 version: 5.0.10(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) next: - specifier: 13.5.1 + specifier: ^13.5.1 version: 13.5.1(@babel/core@7.23.9)(babel-plugin-macros@3.1.0)(react-dom@18.2.0)(react@18.2.0) notistack: specifier: 3.0.1