createRelativeSchema() — astro Function Reference
Architecture documentation for the createRelativeSchema() function in relative.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 6d995e63_1ac1_50fe_5376_9f6ee929f914["createRelativeSchema()"] 10a267b8_752d_1abc_9ed2_b64678e9eb4e["relative.ts"] 6d995e63_1ac1_50fe_5376_9f6ee929f914 -->|defined in| 10a267b8_752d_1abc_9ed2_b64678e9eb4e 484080d3_7759_44d9_ee41_b43205bf1aa0["resolveDirAsUrl()"] 6d995e63_1ac1_50fe_5376_9f6ee929f914 -->|calls| 484080d3_7759_44d9_ee41_b43205bf1aa0 style 6d995e63_1ac1_50fe_5376_9f6ee929f914 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/config/schemas/relative.ts lines 16–151
export function createRelativeSchema(cmd: string, fileProtocolRoot: string) {
let originalBuildClient: string;
let originalBuildServer: string;
// We need to extend the global schema to add transforms that are relative to root.
// This is type checked against the global schema to make sure we still match.
const AstroConfigRelativeSchema = AstroConfigSchema.extend({
root: z
.string()
.default(ASTRO_CONFIG_DEFAULTS.root)
.transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
srcDir: z
.string()
.default(ASTRO_CONFIG_DEFAULTS.srcDir)
.transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
compressHTML: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.compressHTML),
publicDir: z
.string()
.default(ASTRO_CONFIG_DEFAULTS.publicDir)
.transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
outDir: z
.string()
.default(ASTRO_CONFIG_DEFAULTS.outDir)
.transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
cacheDir: z
.string()
.default(ASTRO_CONFIG_DEFAULTS.cacheDir)
.transform((val) => resolveDirAsUrl(val, fileProtocolRoot)),
build: z
.object({
format: z
.union([z.literal('file'), z.literal('directory'), z.literal('preserve')])
.optional()
.default(ASTRO_CONFIG_DEFAULTS.build.format),
// NOTE: `client` and `server` are transformed relative to the default outDir first,
// later we'll fix this to be relative to the actual `outDir`
client: z
.string()
.optional()
.default(ASTRO_CONFIG_DEFAULTS.build.client)
.transform((val) => {
originalBuildClient = val;
return resolveDirAsUrl(
val,
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir),
);
}),
server: z
.string()
.optional()
.default(ASTRO_CONFIG_DEFAULTS.build.server)
.transform((val) => {
originalBuildServer = val;
return resolveDirAsUrl(
val,
path.resolve(fileProtocolRoot, ASTRO_CONFIG_DEFAULTS.outDir),
);
}),
assets: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.assets),
assetsPrefix: z
.string()
.optional()
.or(z.object({ fallback: z.string() }).and(z.record(z.string(), z.string())).optional()),
serverEntry: z.string().optional().default(ASTRO_CONFIG_DEFAULTS.build.serverEntry),
redirects: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.build.redirects),
inlineStylesheets: z
.enum(['always', 'auto', 'never'])
.optional()
.default(ASTRO_CONFIG_DEFAULTS.build.inlineStylesheets),
concurrency: z.number().min(1).optional().default(ASTRO_CONFIG_DEFAULTS.build.concurrency),
})
.optional()
.prefault({}),
server: z.preprocess(
// preprocess
(val) => {
if (typeof val === 'function') {
return val({ command: cmd === 'dev' ? 'dev' : 'preview' });
}
return val;
},
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does createRelativeSchema() do?
createRelativeSchema() is a function in the astro codebase, defined in packages/astro/src/core/config/schemas/relative.ts.
Where is createRelativeSchema() defined?
createRelativeSchema() is defined in packages/astro/src/core/config/schemas/relative.ts at line 16.
What does createRelativeSchema() call?
createRelativeSchema() calls 1 function(s): resolveDirAsUrl.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free