Home / File/ config.ts — astro Source File

config.ts — astro Source File

Architecture documentation for config.ts, a typescript file in the astro codebase. 13 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 13 imports 6 functions

Entity Profile

Dependency Diagram

graph LR
  b7dad900_b555_952f_158e_89aff4cc3f3d["config.ts"]
  e62808d9_0c55_b3a9_00c0_ce588f164dab["../events/index.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> e62808d9_0c55_b3a9_00c0_ce588f164dab
  c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> c32d12e2_d85e_28c0_eea7_9b29629857e0
  dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f["../../core/errors/errors.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f
  ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9
  8db17b08_b9e5_db7e_cd39_46be76c6d5ad["../core/messages.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> 8db17b08_b9e5_db7e_cd39_46be76c6d5ad
  e53a8145_c0cb_5ad0_0494_6de420c6265c["../core/config/merge.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> e53a8145_c0cb_5ad0_0494_6de420c6265c
  f7dbbd79_1b30_42d2_a656_b19b2a675798["../core/config/validate.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> f7dbbd79_1b30_42d2_a656_b19b2a675798
  369d7375_b89b_c8ef_d022_27fee4315c86["./vite-load.js"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> 369d7375_b89b_c8ef_d022_27fee4315c86
  e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> d9a92db9_c95e_9165_13ac_24b3d859d946
  10250468_0e83_bd69_43e9_3bcef2294a91["piccolore"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> 10250468_0e83_bd69_43e9_3bcef2294a91
  a2586aae_ce09_613d_4444_659268b61a89["core"]
  b7dad900_b555_952f_158e_89aff4cc3f3d --> a2586aae_ce09_613d_4444_659268b61a89
  style b7dad900_b555_952f_158e_89aff4cc3f3d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import colors from 'piccolore';
import { $ZodError } from 'zod/v4/core';
import { eventConfigError, telemetry } from '../../events/index.js';
import type {
	AstroConfig,
	AstroInlineConfig,
	AstroInlineOnlyConfig,
	AstroUserConfig,
} from '../../types/public/config.js';
import { trackAstroConfigZodError } from '../errors/errors.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { formatConfigErrorMessage } from '../messages.js';
import { mergeConfig } from './merge.js';
import { validateConfig } from './validate.js';
import { loadConfigWithVite } from './vite-load.js';

export function resolveRoot(cwd?: string | URL): string {
	if (cwd instanceof URL) {
		cwd = fileURLToPath(cwd);
	}
	return cwd ? path.resolve(cwd) : process.cwd();
}

// Config paths to search for.
// In order of likely appearance to speed up the check.
const configPaths = Object.freeze([
	'astro.config.mjs',
	'astro.config.js',
	'astro.config.ts',
	'astro.config.mts',
]);

async function search(fsMod: typeof fs, root: string) {
	const paths = configPaths.map((p) => path.join(root, p));

	for (const file of paths) {
		if (fsMod.existsSync(file)) {
			return file;
		}
	}
}

interface ResolveConfigPathOptions {
	root: string;
	configFile?: string | false;
	fs: typeof fs;
}

/**
 * Resolve the file URL of the user's `astro.config.js|mjs|ts` file
 */
export async function resolveConfigPath(
	options: ResolveConfigPathOptions,
): Promise<string | undefined> {
	let userConfigPath: string | undefined;
	if (options.configFile) {
		userConfigPath = path.join(options.root, options.configFile);
// ... (106 more lines)

Domain

Subdomains

Dependencies

  • ../../core/errors/errors.js
  • ../core/config/merge.js
  • ../core/config/validate.js
  • ../core/errors/index.js
  • ../core/messages.js
  • ../events/index.js
  • ../types/public/config.js
  • ./vite-load.js
  • core
  • node:fs
  • node:path
  • node:url
  • piccolore

Frequently Asked Questions

What does config.ts do?
config.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in config.ts?
config.ts defines 6 function(s): loadConfig, resolveConfig, resolveConfigPath, resolveRoot, search, splitInlineConfig.
What does config.ts depend on?
config.ts imports 13 module(s): ../../core/errors/errors.js, ../core/config/merge.js, ../core/config/validate.js, ../core/errors/index.js, ../core/messages.js, ../events/index.js, ../types/public/config.js, ./vite-load.js, and 5 more.
Where is config.ts in the architecture?
config.ts is located at packages/astro/src/core/config/config.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/config).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free