AstroConfigRefinedSchema() — astro Function Reference
Architecture documentation for the AstroConfigRefinedSchema() function in refined.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 5360069c_f9b4_a639_98fc_1b35299d46d6["AstroConfigRefinedSchema()"] 64f1a8c8_b6f3_9ca7_111f_46db95c72a38["refined.ts"] 5360069c_f9b4_a639_98fc_1b35299d46d6 -->|defined in| 64f1a8c8_b6f3_9ca7_111f_46db95c72a38 style 5360069c_f9b4_a639_98fc_1b35299d46d6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/config/schemas/refined.ts lines 4–189
export const AstroConfigRefinedSchema = z.custom<AstroConfig>().superRefine((config, ctx) => {
if (
config.build.assetsPrefix &&
typeof config.build.assetsPrefix !== 'string' &&
!config.build.assetsPrefix.fallback
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'The `fallback` is mandatory when defining the option as an object.',
path: ['build', 'assetsPrefix'],
});
}
for (let i = 0; i < config.image.remotePatterns.length; i++) {
const { hostname, pathname } = config.image.remotePatterns[i];
if (
hostname &&
hostname.includes('*') &&
!(hostname.startsWith('*.') || hostname.startsWith('**.'))
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'wildcards can only be placed at the beginning of the hostname',
path: ['image', 'remotePatterns', i, 'hostname'],
});
}
if (
pathname &&
pathname.includes('*') &&
!(pathname.endsWith('/*') || pathname.endsWith('/**'))
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'wildcards can only be placed at the end of a pathname',
path: ['image', 'remotePatterns', i, 'pathname'],
});
}
}
if (
config.i18n &&
typeof config.i18n.routing !== 'string' &&
config.i18n.routing.prefixDefaultLocale === false &&
config.i18n.routing.redirectToDefaultLocale === true
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
'The option `i18n.routing.redirectToDefaultLocale` can be used only when `i18n.routing.prefixDefaultLocale` is set to `true`, otherwise redirects might cause infinite loops. Remove the option `i18n.routing.redirectToDefaultLocale`, or change its value to `false`.',
path: ['i18n', 'routing', 'redirectToDefaultLocale'],
});
}
if (config.outDir.toString().startsWith(config.publicDir.toString())) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
'The value of `outDir` must not point to a path within the folder set as `publicDir`, this will cause an infinite loop',
path: ['outDir'],
});
}
if (config.i18n) {
const { defaultLocale, locales: _locales, fallback, domains } = config.i18n;
const locales = _locales.map((locale) => {
if (typeof locale === 'string') {
return locale;
} else {
return locale.path;
}
});
if (!locales.includes(defaultLocale)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `The default locale \`${defaultLocale}\` is not present in the \`i18n.locales\` array.`,
path: ['i18n', 'locales'],
});
}
if (fallback) {
Domain
Subdomains
Source
Frequently Asked Questions
What does AstroConfigRefinedSchema() do?
AstroConfigRefinedSchema() is a function in the astro codebase, defined in packages/astro/src/core/config/schemas/refined.ts.
Where is AstroConfigRefinedSchema() defined?
AstroConfigRefinedSchema() is defined in packages/astro/src/core/config/schemas/refined.ts at line 4.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free