From b6c38e81e73f1a49e3ed4285f068ddc47ae99e82 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Wed, 8 Jan 2025 16:14:55 +0000 Subject: [PATCH] fix(nextjs): use 'next start' for serveStaticTarget --- .../files/common/next-env.d.ts__tmpl__ | 2 +- .../plugins/__snapshots__/plugin.spec.ts.snap | 20 +++++++++---------- packages/next/src/plugins/plugin.ts | 9 +++++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/next/src/generators/application/files/common/next-env.d.ts__tmpl__ b/packages/next/src/generators/application/files/common/next-env.d.ts__tmpl__ index d8b0ee36a63803..8c2499693c918b 100644 --- a/packages/next/src/generators/application/files/common/next-env.d.ts__tmpl__ +++ b/packages/next/src/generators/application/files/common/next-env.d.ts__tmpl__ @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/<%- appDirType %>/building-your-application/configuring/typescript for more information. +// see https://nextjs.org/docs/<%- appDirType %>/api-reference/config/typescript for more information. diff --git a/packages/next/src/plugins/__snapshots__/plugin.spec.ts.snap b/packages/next/src/plugins/__snapshots__/plugin.spec.ts.snap index 6224c2bbdf1c14..f2ec126ef868df 100644 --- a/packages/next/src/plugins/__snapshots__/plugin.spec.ts.snap +++ b/packages/next/src/plugins/__snapshots__/plugin.spec.ts.snap @@ -40,12 +40,12 @@ exports[`@nx/next/plugin integrated projects should create nodes 1`] = ` }, }, "my-serve-static": { - "executor": "@nx/web:file-server", + "command": "next start", + "dependsOn": [ + "my-build", + ], "options": { - "buildTarget": "my-build", - "port": 3000, - "spa": false, - "staticFilePath": "{projectRoot}/out", + "cwd": "my-app", }, }, "my-start": { @@ -105,12 +105,12 @@ exports[`@nx/next/plugin root projects should create nodes 1`] = ` }, }, "serve-static": { - "executor": "@nx/web:file-server", + "command": "next start", + "dependsOn": [ + "build", + ], "options": { - "buildTarget": "build", - "port": 3000, - "spa": false, - "staticFilePath": "{projectRoot}/out", + "cwd": ".", }, }, "start": { diff --git a/packages/next/src/plugins/plugin.ts b/packages/next/src/plugins/plugin.ts index 2621e37a6fbdf3..6d04a4f53cdc62 100644 --- a/packages/next/src/plugins/plugin.ts +++ b/packages/next/src/plugins/plugin.ts @@ -26,6 +26,9 @@ export interface NextPluginOptions { buildTargetName?: string; devTargetName?: string; startTargetName?: string; + /** + * @deprecated Use `startTargetName` instead. + */ serveStaticTargetName?: string; } @@ -166,9 +169,11 @@ async function buildNextTargets( targets[options.devTargetName] = getDevTargetConfig(projectRoot); - targets[options.startTargetName] = getStartTargetConfig(options, projectRoot); + const startTarget = getStartTargetConfig(options, projectRoot); - targets[options.serveStaticTargetName] = getStaticServeTargetConfig(options); + targets[options.startTargetName] = startTarget; + + targets[options.serveStaticTargetName] = startTarget; return targets; }