|
1 | | -/** @type {import('next').NextConfig} */ |
2 | | -const nextConfig = { |
3 | | - output: 'export', |
4 | | - assetPrefix: '.', |
5 | | - trailingSlash: true, |
6 | | - images: { unoptimized: true }, |
7 | | - // The workspace tsconfig uses path aliases that point at devframe's |
8 | | - // source so source-level edits HMR cleanly. Next.js's incremental TS |
9 | | - // check can't follow workspace project references through those aliases |
10 | | - // and ends up type-checking unrelated source. Defer typechecking to the |
11 | | - // workspace's own `tsc -b` (`pnpm typecheck`), which honors references. |
12 | | - typescript: { ignoreBuildErrors: true }, |
13 | | -} |
| 1 | +import { PHASE_DEVELOPMENT_SERVER } from 'next/constants.js' |
14 | 2 |
|
15 | | -export default nextConfig |
| 3 | +/** |
| 4 | + * The static-export options (`output: 'export'`, a relative `assetPrefix`, and |
| 5 | + * `trailingSlash`) exist so `next build` emits a self-contained SPA that mounts |
| 6 | + * at any base. They are wrong for `next dev`: a relative `assetPrefix` breaks |
| 7 | + * the dev client runtime's chunk base, so the page never hydrates (no |
| 8 | + * interactivity, and the RPC client never connects). Apply them only for the |
| 9 | + * production build so `pnpm dev` hydrates normally. |
| 10 | + * |
| 11 | + * @type {(phase: string) => import('next').NextConfig} |
| 12 | + */ |
| 13 | +export default (phase) => { |
| 14 | + const isDev = phase === PHASE_DEVELOPMENT_SERVER |
| 15 | + return { |
| 16 | + ...(isDev ? {} : { output: 'export', assetPrefix: '.', trailingSlash: true }), |
| 17 | + images: { unoptimized: true }, |
| 18 | + // The workspace tsconfig uses path aliases that point at devframe's |
| 19 | + // source so source-level edits HMR cleanly. Next.js's incremental TS |
| 20 | + // check can't follow workspace project references through those aliases |
| 21 | + // and ends up type-checking unrelated source. Defer typechecking to the |
| 22 | + // workspace's own `tsc -b` (`pnpm typecheck`), which honors references. |
| 23 | + typescript: { ignoreBuildErrors: true }, |
| 24 | + } |
| 25 | +} |
0 commit comments