Skip to content

Commit

Permalink
fix(nextjs): Add debug ability when verbose is passed to build
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham committed Apr 25, 2023
1 parent 87ac061 commit 56ad701
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/next/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createLockFile, createPackageJson, getLockFileName } from '@nx/js';
import build from 'next/dist/build';
import { join, resolve } from 'path';
import { copySync, existsSync, mkdir, writeFileSync } from 'fs-extra';
import { gte } from 'semver';
import { lt, gte } from 'semver';
import { directoryExists } from '@nx/workspace/src/utilities/fileutils';
import { checkAndCleanWithSemver } from '@nx/devkit/src/utils/semver';

Expand Down Expand Up @@ -45,7 +45,17 @@ export default async function buildExecutor(
(process.env as any).__NEXT_REACT_ROOT ||= 'true';
}

await build(root);
// Get the installed Next.js version (will be removed after Nx 16 and Next.js update)
const nextVersion = require('next/package.json')?.version ?? '';

// Check the major and minor version numbers
if (lt(nextVersion, '13.2.0')) {
// If the version is lower than 13.2.0, use the second parameter as the config object
await build(root, null, false, !!process.env.NX_VERBOSE_LOGGING);
} else {
// Otherwise, use the third parameter as a boolean flag for verbose logging
await build(root, false, !!process.env.NX_VERBOSE_LOGGING);
}

if (!directoryExists(options.outputPath)) {
mkdir(options.outputPath);
Expand Down

0 comments on commit 56ad701

Please sign in to comment.