Skip to content

Commit

Permalink
fix: use next/package.json instead of project dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sambrodie committed Aug 7, 2024
1 parent 1e10cd0 commit 61996ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/next/src/config/withHeadstartWPConfig.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ConfigError, HeadlessConfig } from '@headstartwp/core';
import { NextConfig } from 'next';
import fs from 'fs';
import path from 'path';
import { ModifySourcePlugin, ConcatOperation } from './plugins/ModifySourcePlugin';

// Get the path to the project's root package.json
const packageJsonPath = path.join(process.cwd(), 'package.json');
const packageJson = packageJsonPath ? JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) : {};
// Use require.resolve to get the path to the package.json
const nextPackageJsonPath = require.resolve('next/package.json');
const nextPackageJson = nextPackageJsonPath
? JSON.parse(fs.readFileSync(nextPackageJsonPath, 'utf8'))
: {};

type RemotePattern = {
protocol?: 'http' | 'https';
Expand Down Expand Up @@ -148,7 +149,7 @@ export function withHeadstartWPConfig(
}
});

const useImageRemotePatterns = meetsMinimumVersion(packageJson?.dependencies?.next, 14);
const useImageRemotePatterns = meetsMinimumVersion(nextPackageJson?.version, 14);
const imageConfig: { domains?: string[]; remotePatterns?: RemotePattern[] } = {};

if (useImageRemotePatterns) {
Expand Down

0 comments on commit 61996ed

Please sign in to comment.