MCPcopy
hub / github.com/vitejs/vite / doImportCSSReplace

Function doImportCSSReplace

packages/vite/src/node/plugins/css.ts:2190–2213  ·  view source on GitHub ↗
(
  rawUrl: string,
  matched: string,
  replacer: CssUrlReplacer,
)

Source from the content-addressed store, hash-verified

2188}
2189
2190async function doImportCSSReplace(
2191 rawUrl: string,
2192 matched: string,
2193 replacer: CssUrlReplacer,
2194) {
2195 let wrap = ''
2196 const first = rawUrl[0]
2197 let unquotedUrl = rawUrl
2198 if (first === `"` || first === `'`) {
2199 wrap = first
2200 unquotedUrl = rawUrl.slice(1, -1)
2201 }
2202 if (skipUrlReplacer(unquotedUrl)) {
2203 return matched
2204 }
2205
2206 const newUrl = await replacer(unquotedUrl, rawUrl)
2207 if (newUrl === false) {
2208 return matched
2209 }
2210
2211 const prefix = matched.includes('url(') ? 'url(' : ''
2212 return `@import ${prefix}${wrap}${newUrl}${wrap}`
2213}
2214
2215async function minifyCSS(
2216 css: string,

Callers 1

rewriteImportCssFunction · 0.85

Calls 2

skipUrlReplacerFunction · 0.85
replacerFunction · 0.85

Tested by

no test coverage detected