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

Function assetToDataURL

packages/vite/src/node/plugins/asset.ts:568–586  ·  packages/vite/src/node/plugins/asset.ts::assetToDataURL
(
  environment: Environment,
  file: string,
  content: Buffer,
)

Source from the content-addressed store, hash-verified

566}
567
568function assetToDataURL(
569 environment: Environment,
570 file: string,
571 content: Buffer,
572) {
573 if (environment.config.build.lib && isGitLfsPlaceholder(content)) {
574 environment.logger.warn(
575 colors.yellow(`Inlined file ${file} was not downloaded via Git LFS`),
576 )
577 }
578
579 if (file.endsWith(class="st">'.svg')) {
580 return svgToDataURL(content)
581 } else {
582 const mimeType = mrmime.lookup(file) ?? class="st">'application/octet-stream'
583 class="cm">// base64 inlined as a string
584 return `data:${mimeType};base64,${content.toString(class="st">'base64')}`
585 }
586}
587
588const nestedQuotesRE = /class="st">"[^"class="st">']*'[^class="st">"]*"|class="st">'[^'class="st">"]*"[^class="st">']*'/
589

Callers 2

fileToDevUrlFunction · 0.85
fileToBuiltUrlFunction · 0.85

Calls 3

isGitLfsPlaceholderFunction · 0.85
svgToDataURLFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected