asset.ts — vite Source File
Architecture documentation for asset.ts, a typescript file in the vite codebase. 36 imports, 8 dependents.
Entity Profile
Dependency Diagram
graph LR e71b94ef_3010_e358_13d8_f3b3acb0a268["asset.ts"] 45981d85_cbdd_e969_8c88_c17072ea0eda["build.ts"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 45981d85_cbdd_e969_8c88_c17072ea0eda c25246ea_7a11_06af_dc93_7717f85216db["createToImportMetaURLBasedRelativeRuntime"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> c25246ea_7a11_06af_dc93_7717f85216db 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66["toOutputFilePathInJS"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66 5abb8c87_ffcb_f2d4_7421_e36705d9e5c7["plugin.ts"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 5abb8c87_ffcb_f2d4_7421_e36705d9e5c7 1dc2cf7d_5d97_c778_8c33_6449a7607aef["Plugin"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 1dc2cf7d_5d97_c778_8c33_6449a7607aef 7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 7da774f9_eca5_d54e_6e01_6bee7d460a2b eb5604c2_58e1_1c00_5a1a_5d97ea5236ad["ResolvedConfig"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> eb5604c2_58e1_1c00_5a1a_5d97ea5236ad c6b6e85a_866b_a3e1_08e0_f9aa4550a2d3["publicDir.ts"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> c6b6e85a_866b_a3e1_08e0_f9aa4550a2d3 be351481_35b7_f392_a229_ac14e1fa7efb["checkPublicFile"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> be351481_35b7_f392_a229_ac14e1fa7efb 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2 41d0f7a0_ed36_9f0f_d0d6_f403e4f50763["encodeURIPath"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 41d0f7a0_ed36_9f0f_d0d6_f403e4f50763 9d025481_71dc_8fbb_c07e_b6e74a08a45a["getHash"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 9d025481_71dc_8fbb_c07e_b6e74a08a45a 1948f092_e5a5_076b_2f59_79ef22dec191["injectQuery"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> 1948f092_e5a5_076b_2f59_79ef22dec191 c9db8630_93b3_267d_8e26_8b62626a11ca["joinUrlSegments"] e71b94ef_3010_e358_13d8_f3b3acb0a268 --> c9db8630_93b3_267d_8e26_8b62626a11ca style e71b94ef_3010_e358_13d8_f3b3acb0a268 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from 'node:path'
import fsp from 'node:fs/promises'
import { Buffer } from 'node:buffer'
import { pathToFileURL } from 'node:url'
import * as mrmime from 'mrmime'
import type {
NormalizedOutputOptions,
PluginContext,
RenderedChunk,
} from 'rolldown'
import MagicString from 'magic-string'
import colors from 'picocolors'
import picomatch from 'picomatch'
import { makeIdFiltersToMatchWithQuery } from 'rolldown/filter'
import {
createToImportMetaURLBasedRelativeRuntime,
toOutputFilePathInJS,
} from '../build'
import type { Plugin } from '../plugin'
import type { ResolvedConfig } from '../config'
import { checkPublicFile } from '../publicDir'
import {
encodeURIPath,
getHash,
injectQuery,
joinUrlSegments,
normalizePath,
rawRE,
removeLeadingSlash,
removeUrlQuery,
urlRE,
} from '../utils'
import {
DEFAULT_ASSETS_INLINE_LIMIT,
DEFAULT_ASSETS_RE,
FS_PREFIX,
} from '../constants'
import {
cleanUrl,
splitFileAndPostfix,
withTrailingSlash,
} from '../../shared/utils'
import type { Environment } from '../environment'
import type { PartialEnvironment } from '../baseEnvironment'
// referenceId is base64url but replaces - with $
export const assetUrlRE: RegExp = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g
const jsSourceMapRE = /\.[cm]?js\.map$/
export const noInlineRE: RegExp = /[?&]no-inline\b/
export const inlineRE: RegExp = /[?&]inline\b/
const assetCache = new WeakMap<Environment, Map<string, string>>()
/** a set of referenceId for entry CSS assets for each environment */
export const cssEntriesMap: WeakMap<
Environment,
Map<string, string>
> = new WeakMap()
// ... (558 more lines)
Domain
Subdomains
Functions
Dependencies
- Environment
- PartialEnvironment
- Plugin
- ResolvedConfig
- baseEnvironment.ts
- build.ts
- checkPublicFile
- cleanUrl
- config.ts
- constants.ts
- createToImportMetaURLBasedRelativeRuntime
- encodeURIPath
- environment.ts
- filter
- getHash
- injectQuery
- joinUrlSegments
- magic-string
- mrmime
- node:buffer
- node:path
- node:url
- normalizePath
- picocolors
- picomatch
- plugin.ts
- promises
- publicDir.ts
- removeLeadingSlash
- removeUrlQuery
- rolldown
- splitFileAndPostfix
- toOutputFilePathInJS
- utils.ts
- utils.ts
- withTrailingSlash
Imported By
- packages/vite/src/node/plugins/assetImportMetaUrl.ts
- packages/vite/src/node/plugins/css.ts
- packages/vite/src/node/plugins/html.ts
- packages/vite/src/node/plugins/index.ts
- packages/vite/src/node/plugins/manifest.ts
- packages/vite/src/node/plugins/wasm.ts
- packages/vite/src/node/plugins/worker.ts
- packages/vite/src/node/plugins/workerImportMetaUrl.ts
Source
Frequently Asked Questions
What does asset.ts do?
asset.ts is a source file in the vite codebase, written in typescript. It belongs to the PluginSystem domain, AssetManagement subdomain.
What functions are defined in asset.ts?
asset.ts defines 14 function(s): assetPlugin, assetToDataURL, fileToBuiltUrl, fileToDevUrl, fileToUrl, getPublicAssetFilename, isGitLfsPlaceholder, publicFileToBuiltUrl, registerCustomMime, renderAssetUrlInJS, and 4 more.
What does asset.ts depend on?
asset.ts imports 36 module(s): Environment, PartialEnvironment, Plugin, ResolvedConfig, baseEnvironment.ts, build.ts, checkPublicFile, cleanUrl, and 28 more.
What files import asset.ts?
asset.ts is imported by 8 file(s): assetImportMetaUrl.ts, css.ts, html.ts, index.ts, manifest.ts, wasm.ts, worker.ts, workerImportMetaUrl.ts.
Where is asset.ts in the architecture?
asset.ts is located at packages/vite/src/node/plugins/asset.ts (domain: PluginSystem, subdomain: AssetManagement, directory: packages/vite/src/node/plugins).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free