From b16f9058e86fdf674fc28d6d7ee1fdf8227968dc Mon Sep 17 00:00:00 2001 From: Dan Roujinsky Date: Tue, 20 Feb 2024 12:31:55 +0200 Subject: [PATCH] fix(webpack): correctly handle paranthesis in PostCSS in url --- .../src/utils/webpack/plugins/postcss-cli-resources.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webpack/src/utils/webpack/plugins/postcss-cli-resources.ts b/packages/webpack/src/utils/webpack/plugins/postcss-cli-resources.ts index adab906ba5b35..a8d6926dbc5c8 100644 --- a/packages/webpack/src/utils/webpack/plugins/postcss-cli-resources.ts +++ b/packages/webpack/src/utils/webpack/plugins/postcss-cli-resources.ts @@ -152,7 +152,7 @@ export function PostcssCliResources(options: PostcssCliResourcesOptions) { return Promise.all( urlDeclarations.map(async (decl) => { const value = decl.value; - const urlRegex = /url(?:\(\s*['"]?)(.*?)(?:['"]?\s*\))/g; + const urlRegex = /url(?:\(\s*(['"]?))(.*?)(?:\1\s*\))/g; const segments: string[] = []; let match; let lastIndex = 0; @@ -162,7 +162,7 @@ export function PostcssCliResources(options: PostcssCliResourcesOptions) { const context = (inputFile && path.dirname(inputFile)) || loader.context; while ((match = urlRegex.exec(value))) { - const originalUrl = match[1]; + const originalUrl = match[2]; let processedUrl; try { processedUrl = await process(originalUrl, context, resourceCache);