Skip to content

Commit

Permalink
fix(plugin): fix cssLoader to exclude a data URL (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
sondh0127 authored Aug 31, 2022
1 parent 34d460d commit 61546fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/wujie-core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export function isMatchUrl(url: string, effectLoaders: plugin[effectLoadersType]
*/
function cssRelativePathResolve(code: string, src: string, base: string) {
const baseUrl = src ? getAbsolutePath(src, base) : base;
const urlReg = /(url\()([^)]*)(\))/g;
// https://developer.mozilla.org/en-US/docs/Web/CSS/url
const urlReg = /(url\((?!['"]?(?:data):)['"]?)([^'"\)]*)(['"]?\))/g;
return code.replace(urlReg, (_m, pre, url, post) => {
const urlString = url.replace(/["']/g, "");
const absoluteUrl = getAbsolutePath(urlString, baseUrl);
return pre + "'" + absoluteUrl + "'" + post;
const absoluteUrl = getAbsolutePath(url, baseUrl);
return pre + absoluteUrl + post;
});
}

Expand Down

0 comments on commit 61546fb

Please sign in to comment.