Skip to content

Commit

Permalink
fix: purify asset urls extracted from style file #11
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-layne committed Aug 1, 2023
1 parent faec0ed commit c7cb4bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ export default function VitePluginLibAssets(options: Options = {}): Plugin {
const cssUrlAssets = getCaptured(source, cssUrlRE)
const cssImageSetAssets = getCaptured(source, cssImageSetRE)
const assets = [...cssUrlAssets, ...cssImageSetAssets]
const pureAssets = assets.map(asset =>
asset.startsWith('\'') || asset.startsWith('"')
? asset.slice(1, -1)
: asset,
)

const importerDir = id.endsWith('/') ? id : path.dirname(id)
return Array.from(new Set(assets.map(asset => path.resolve(importerDir, asset))))
return Array.from(new Set(pureAssets.map(asset => path.resolve(importerDir, asset))))
}

return {
Expand Down

0 comments on commit c7cb4bd

Please sign in to comment.