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

Function publicFileToBuiltUrl

packages/vite/src/node/plugins/asset.ts:394–412  ·  packages/vite/src/node/plugins/asset.ts::publicFileToBuiltUrl
(
  url: string,
  config: ResolvedConfig,
)

Source from the content-addressed store, hash-verified

392export const publicAssetUrlRE: RegExp = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g
393
394export function publicFileToBuiltUrl(
395 url: string,
396 config: ResolvedConfig,
397): string {
398 if (config.command !== class="st">'build') {
399 class="cm">// We don't need relative base or renderBuiltUrl support during dev
400 return joinUrlSegments(config.decodedBase, url)
401 }
402 const hash = getHash(url)
403 let cache = publicAssetUrlCache.get(config)
404 if (!cache) {
405 cache = new Map<string, string>()
406 publicAssetUrlCache.set(config, cache)
407 }
408 if (!cache.get(hash)) {
409 cache.set(hash, url)
410 }
411 return `__VITE_PUBLIC_ASSET__${hash}__`
412}
413
414const GIT_LFS_PREFIX = Buffer.from(class="st">'version https:class="cm">//git-lfs.github.com')
415function isGitLfsPlaceholder(content: Buffer): boolean {

Callers 3

urlResolverFunction · 0.90
fileToBuiltUrlFunction · 0.85
urlToBuiltUrlFunction · 0.85

Calls 4

joinUrlSegmentsFunction · 0.90
getHashFunction · 0.90
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected