Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Fix order, and wrong number call to createWebpackConfig() #27337

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/next/plugins/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,22 @@ 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) =>
createWebpackConfig(
_nextConfig.nx?.fileReplacements
? joinPathFragments(workspaceRoot, projectDirectory)
: workspaceRoot,
_nextConfig.nx?.assets || options.assets,
_nextConfig.nx?.fileReplacements || options.fileReplacements
projectDirectory,
_nextConfig.nx?.fileReplacements || options.fileReplacements,
_nextConfig.nx?.assets || options.assets
)(userWebpackConfig ? userWebpackConfig(a, b) : a, b);

return nextConfig;
Expand Down