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);