static.ts — vite Source File
Architecture documentation for static.ts, a typescript file in the vite codebase. 24 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR d91d6c8f_e2c2_3b92_12c3_391c9ba06183["static.ts"] a423a1ed_f7d8_0eb5_9b8f_ddfa7fa8147e["index.ts"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> a423a1ed_f7d8_0eb5_9b8f_ddfa7fa8147e 31fbe894_2070_4b11_3ffa_96b46ed3dfa9["ViteDevServer"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 31fbe894_2070_4b11_3ffa_96b46ed3dfa9 7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 7da774f9_eca5_d54e_6e01_6bee7d460a2b eb5604c2_58e1_1c00_5a1a_5d97ea5236ad["ResolvedConfig"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> eb5604c2_58e1_1c00_5a1a_5d97ea5236ad 545df65b_7f67_94d3_e2e8_a592d5e64b8f["constants.ts"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 545df65b_7f67_94d3_e2e8_a592d5e64b8f 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2 b785bb42_81b4_52a8_f27e_13aacc0eea06["decodeURIIfPossible"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> b785bb42_81b4_52a8_f27e_13aacc0eea06 1c19c7da_486b_6fa0_e7ab_0c3784456fc6["fsPathFromUrl"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 1c19c7da_486b_6fa0_e7ab_0c3784456fc6 98952751_e0cf_2bf3_c4a0_2fde2526872b["isFileReadable"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 98952751_e0cf_2bf3_c4a0_2fde2526872b 13d1ff08_16f8_81bc_1a7a_cd281614a4d3["isImportRequest"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 13d1ff08_16f8_81bc_1a7a_cd281614a4d3 02cc1763_d5fc_6d3a_58ef_310caf680b7e["isInternalRequest"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 02cc1763_d5fc_6d3a_58ef_310caf680b7e d9d49dad_960b_4712_7c44_9345473c62e5["isParentDirectory"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> d9d49dad_960b_4712_7c44_9345473c62e5 1bfe2c56_df21_a80a_d46e_8e769fa0b467["isSameFilePath"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> 1bfe2c56_df21_a80a_d46e_8e769fa0b467 a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath"] d91d6c8f_e2c2_3b92_12c3_391c9ba06183 --> a4adb1a7_cf54_091f_eb63_8217e684a8e1 style d91d6c8f_e2c2_3b92_12c3_391c9ba06183 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from 'node:path'
import type { OutgoingHttpHeaders, ServerResponse } from 'node:http'
import type { Options } from 'sirv'
import sirv from 'sirv'
import escapeHtml from 'escape-html'
import type { Connect } from '#dep-types/connect'
import type { ViteDevServer } from '../../server'
import type { ResolvedConfig } from '../../config'
import { FS_PREFIX } from '../../constants'
import {
decodeURIIfPossible,
fsPathFromUrl,
isFileReadable,
isImportRequest,
isInternalRequest,
isParentDirectory,
isSameFilePath,
normalizePath,
removeLeadingSlash,
urlRE,
} from '../../utils'
import {
cleanUrl,
isWindows,
slash,
withTrailingSlash,
} from '../../../shared/utils'
const knownJavascriptExtensionRE = /\.(?:[tj]sx?|[cm][tj]s)$/
const ERR_DENIED_FILE = 'ERR_DENIED_FILE'
const sirvOptions = ({
config,
getHeaders,
disableFsServeCheck,
}: {
config: ResolvedConfig
getHeaders: () => OutgoingHttpHeaders | undefined
disableFsServeCheck?: boolean
}): Options => {
return {
dev: true,
etag: true,
extensions: [],
setHeaders(res, pathname) {
// Matches js, jsx, ts, tsx, mts, mjs, cjs, cts, ctx, mtx
// The reason this is done, is that the .ts and .mts file extensions are
// reserved for the MIME type video/mp2t. In almost all cases, we can expect
// these files to be TypeScript files, and for Vite to serve them with
// this Content-Type.
if (knownJavascriptExtensionRE.test(pathname)) {
res.setHeader('Content-Type', 'text/javascript')
}
const headers = getHeaders()
if (headers) {
for (const name in headers) {
res.setHeader(name, headers[name]!)
}
}
},
// ... (302 more lines)
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does static.ts do?
static.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in static.ts?
static.ts defines 10 function(s): checkLoadingAccess, isFileInTargetPath, isFileLoadingAllowed, isFileServingAllowed, renderRestrictedErrorHTML, respondWithAccessDenied, servePublicMiddleware, serveRawFsMiddleware, serveStaticMiddleware, sirvOptions.
What does static.ts depend on?
static.ts imports 24 module(s): ResolvedConfig, ViteDevServer, cleanUrl, config.ts, connect, constants.ts, decodeURIIfPossible, escape-html, and 16 more.
What files import static.ts?
static.ts is imported by 5 file(s): index.ts, indexHtml.ts, static.spec.ts, transform.ts, transformRequest.ts.
Where is static.ts in the architecture?
static.ts is located at packages/vite/src/node/server/middlewares/static.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/server/middlewares).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free