From 8899fb9e36556debe3b262f27c1b6e94c4963144 Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Fri, 27 Oct 2023 18:16:06 -0700 Subject: [PATCH] fix(@ngtools/webpack): skip transforming empty inline styles in Webpack JIT compilations Empty styles break the Webpack resource loader / PostCSS and generate an error. Fortunately there's no work to be done there, so we can just skip it and leave the empty string. (cherry picked from commit 7b02161e94fe583ad732c3a5830d8b1ca91ab379) --- .../ngtools/webpack/src/transformers/replace_resources.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/ngtools/webpack/src/transformers/replace_resources.ts b/packages/ngtools/webpack/src/transformers/replace_resources.ts index 2a6adf29c07e..c31f171d1fb4 100644 --- a/packages/ngtools/webpack/src/transformers/replace_resources.ts +++ b/packages/ngtools/webpack/src/transformers/replace_resources.ts @@ -236,6 +236,11 @@ function transformInlineStyleLiteral( return node; } + // Don't transform empty strings as PostCSS will choke on them. No work to do anyways. + if (node.text === '') { + return node; + } + if (!isInlineStyle) { const url = getResourceUrl(node);