Skip to content

Commit

Permalink
fix(css): skip comma when matching css url
Browse files Browse the repository at this point in the history
  • Loading branch information
ikeq committed Jun 28, 2021
1 parent f3643d8 commit dea7991
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ type CssUrlReplacer = (
) => string | Promise<string>
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
export const cssUrlRE =
/(?:^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/
/(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/
const cssImageSetRE = /image-set\(([^)]+)\)/

const UrlRewritePostcssPlugin: Postcss.PluginCreator<{
Expand Down Expand Up @@ -837,9 +837,7 @@ async function doUrlReplace(
return matched
}

// #3926
const initialComma = matched[0] === ',' ? ',' : ''
return `${initialComma}url(${wrap}${await replacer(rawUrl)}${wrap})`
return `url(${wrap}${await replacer(rawUrl)}${wrap})`
}

let CleanCSS: any
Expand Down

0 comments on commit dea7991

Please sign in to comment.