From 3936b6e6554524433bd552f5f102765fffad5b3c Mon Sep 17 00:00:00 2001 From: Thomas Blanchard Date: Thu, 3 Nov 2022 17:55:47 +0100 Subject: [PATCH] fix(core): error in with-nx.ts Correct "Cannot read properties of undefined (reading 'and')" error when serve Next app --- packages/next/plugins/with-nx.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 7fe8d70265006..135b4db94bc4c 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -79,7 +79,7 @@ export function withNx( rule.sideEffects === false && regexEqual(rule.test, /\.module\.css$/) ); // Might not be found if Next.js webpack config changes in the future - if (nextCssLoader) { + if (nextCssLoader && nextCssLoader.issuer) { nextCssLoader.issuer.or = nextCssLoader.issuer.and ? nextCssLoader.issuer.and.concat(includes) : includes; @@ -95,7 +95,7 @@ export function withNx( regexEqual(rule.test, /\.module\.(scss|sass)$/) ); // Might not be found if Next.js webpack config changes in the future - if (nextSassLoader) { + if (nextSassLoader && nextSassLoader.issuer) { nextSassLoader.issuer.or = nextSassLoader.issuer.and ? nextSassLoader.issuer.and.concat(includes) : includes; @@ -130,7 +130,7 @@ export function withNx( ) ); // Might not be found if Next.js webpack config changes in the future - if (nextGlobalCssLoader) { + if (nextGlobalCssLoader && nextGlobalCssLoader.issuer) { nextGlobalCssLoader.issuer.or = nextGlobalCssLoader.issuer.and ? nextGlobalCssLoader.issuer.and.concat(includes) : includes;