From e01e26dc93070b995d75784bb48e97a024148338 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 6 May 2020 15:56:50 -0400 Subject: [PATCH] fix: skip asset processing for data uri in css fix #66 --- src/node/buildPluginAsset.ts | 2 +- src/node/buildPluginCss.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/node/buildPluginAsset.ts b/src/node/buildPluginAsset.ts index bb0dad9dffc7d0..fc166f5d69d2ba 100644 --- a/src/node/buildPluginAsset.ts +++ b/src/node/buildPluginAsset.ts @@ -77,7 +77,7 @@ export const createBuildAssetPlugin = ( inlineLimit ) assets.set(fileName, content) - debug(`${id} -> ${url}`) + debug(`${id} -> ${url.startsWith('data:') ? `base64 inlined` : url}`) return `export default ${JSON.stringify(url)}` } }, diff --git a/src/node/buildPluginCss.ts b/src/node/buildPluginCss.ts index e26ee04364c738..3ee612b0b77d18 100644 --- a/src/node/buildPluginCss.ts +++ b/src/node/buildPluginCss.ts @@ -31,7 +31,7 @@ export const createBuildCssPlugin = ( css, urlRE, async ([matched, before, rawUrl, after]) => { - if (isExternalUrl(rawUrl)) { + if (isExternalUrl(rawUrl) || rawUrl.startsWith('data:')) { return matched } const file = path.join(fileDir, rawUrl) @@ -42,7 +42,11 @@ export const createBuildCssPlugin = ( inlineLimit ) assets.set(fileName, content) - debug(`url(${rawUrl}) -> url(${url})`) + debug( + `url(${rawUrl}) -> ${ + url.startsWith('data:') ? `base64 inlined` : `url(${url})` + }` + ) return `${before}${url}${after}` } )