assetToDataURL() — vite Function Reference
Architecture documentation for the assetToDataURL() function in asset.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 116d8e93_bf90_f56d_0ddc_02033886ac39["assetToDataURL()"] e71b94ef_3010_e358_13d8_f3b3acb0a268["asset.ts"] 116d8e93_bf90_f56d_0ddc_02033886ac39 -->|defined in| e71b94ef_3010_e358_13d8_f3b3acb0a268 eec82f76_7029_ae97_4449_1665a4f204d8["fileToDevUrl()"] eec82f76_7029_ae97_4449_1665a4f204d8 -->|calls| 116d8e93_bf90_f56d_0ddc_02033886ac39 86195de2_9c12_1f7e_7a3e_0754a5695ebe["fileToBuiltUrl()"] 86195de2_9c12_1f7e_7a3e_0754a5695ebe -->|calls| 116d8e93_bf90_f56d_0ddc_02033886ac39 a1a54c72_e5af_63a4_544f_313ad8815637["isGitLfsPlaceholder()"] 116d8e93_bf90_f56d_0ddc_02033886ac39 -->|calls| a1a54c72_e5af_63a4_544f_313ad8815637 34490843_2d64_5c9c_97a9_18c388480f7b["svgToDataURL()"] 116d8e93_bf90_f56d_0ddc_02033886ac39 -->|calls| 34490843_2d64_5c9c_97a9_18c388480f7b style 116d8e93_bf90_f56d_0ddc_02033886ac39 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/asset.ts lines 567–585
function assetToDataURL(
environment: Environment,
file: string,
content: Buffer,
) {
if (environment.config.build.lib && isGitLfsPlaceholder(content)) {
environment.logger.warn(
colors.yellow(`Inlined file ${file} was not downloaded via Git LFS`),
)
}
if (file.endsWith('.svg')) {
return svgToDataURL(content)
} else {
const mimeType = mrmime.lookup(file) ?? 'application/octet-stream'
// base64 inlined as a string
return `data:${mimeType};base64,${content.toString('base64')}`
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does assetToDataURL() do?
assetToDataURL() is a function in the vite codebase, defined in packages/vite/src/node/plugins/asset.ts.
Where is assetToDataURL() defined?
assetToDataURL() is defined in packages/vite/src/node/plugins/asset.ts at line 567.
What does assetToDataURL() call?
assetToDataURL() calls 2 function(s): isGitLfsPlaceholder, svgToDataURL.
What calls assetToDataURL()?
assetToDataURL() is called by 2 function(s): fileToBuiltUrl, fileToDevUrl.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free