Skip to content

Commit

Permalink
fix: skip asset processing for data uri in css
Browse files Browse the repository at this point in the history
fix #66
  • Loading branch information
yyx990803 committed May 6, 2020
1 parent 5f05f1e commit e01e26d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node/buildPluginAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`
}
},
Expand Down
8 changes: 6 additions & 2 deletions src/node/buildPluginCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}`
}
)
Expand Down

0 comments on commit e01e26d

Please sign in to comment.