diff --git a/packages/next/src/generators/application/lib/add-project.ts b/packages/next/src/generators/application/lib/add-project.ts index f94d4109ed4e8..14a1cf1c0a7ec 100644 --- a/packages/next/src/generators/application/lib/add-project.ts +++ b/packages/next/src/generators/application/lib/add-project.ts @@ -9,13 +9,18 @@ import { export function addProject(host: Tree, options: NormalizedSchema) { const targets: Record = {}; + const outputPath = joinPathFragments( + 'dist', + options.appProjectRoot, + ...(options.rootProject ? [options.name] : []) + ); targets.build = { executor: '@nx/next:build', outputs: ['{options.outputPath}'], defaultConfiguration: 'production', options: { root: options.appProjectRoot, - outputPath: joinPathFragments('dist', options.appProjectRoot), + outputPath: outputPath, }, configurations: { development: { diff --git a/packages/next/src/generators/application/lib/create-application-files.ts b/packages/next/src/generators/application/lib/create-application-files.ts index 8829ff25fdf5a..d70728da10ce5 100644 --- a/packages/next/src/generators/application/lib/create-application-files.ts +++ b/packages/next/src/generators/application/lib/create-application-files.ts @@ -80,6 +80,7 @@ export function createApplicationFiles(host: Tree, options: NormalizedSchema) { ...(updatedJson.exclude || []), ...(appJSON.exclude || []), '**e2e/**/*', + `dist/${options.name}/**/*`, ]), ], };