Skip to content

Commit

Permalink
fix(nextjs): Add typing for createWebpackConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham committed Aug 13, 2024
1 parent 103e248 commit 988732a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/next/plugins/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ function withNx(

const userWebpackConfig = nextConfig.webpack;

const { createWebpackConfig } = require('@nx/next/src/utils/config');
const { createWebpackConfig } = require(require.resolve(
'@nx/next/src/utils/config',
{
paths: [workspaceRoot],
}
)) as typeof import('@nx/next/src/utils/config');
// If we have file replacements or assets, inside of the next config we pass the workspaceRoot as a join of the workspaceRoot and the projectDirectory
// Because the file replacements and assets are relative to the projectRoot, not the workspaceRoot
nextConfig.webpack = (a, b) =>
Expand All @@ -221,8 +226,8 @@ function withNx(
? joinPathFragments(workspaceRoot, projectDirectory)
: workspaceRoot,
projectDirectory,
_nextConfig.nx?.fileReplacements || options.fileReplacements,
_nextConfig.nx?.assets || options.assets
_nextConfig.nx?.assets || options.assets,
_nextConfig.nx?.fileReplacements || options.fileReplacements
)(userWebpackConfig ? userWebpackConfig(a, b) : a, b);

return nextConfig;
Expand Down

0 comments on commit 988732a

Please sign in to comment.