Home / Function/ resolveConfig() — astro Function Reference

resolveConfig() — astro Function Reference

Architecture documentation for the resolveConfig() function in config.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  0d1ab03e_04f2_35e7_7e2d_93764ee4f484["resolveConfig()"]
  b7dad900_b555_952f_158e_89aff4cc3f3d["config.ts"]
  0d1ab03e_04f2_35e7_7e2d_93764ee4f484 -->|defined in| b7dad900_b555_952f_158e_89aff4cc3f3d
  d2c2c2d6_6bf3_0908_ed5d_39c223dba699["resolveRoot()"]
  0d1ab03e_04f2_35e7_7e2d_93764ee4f484 -->|calls| d2c2c2d6_6bf3_0908_ed5d_39c223dba699
  730fcae5_3b39_b19a_ecec_5c64204ce9ed["splitInlineConfig()"]
  0d1ab03e_04f2_35e7_7e2d_93764ee4f484 -->|calls| 730fcae5_3b39_b19a_ecec_5c64204ce9ed
  389cc9ce_16f8_1d39_88ac_521d7093028a["loadConfig()"]
  0d1ab03e_04f2_35e7_7e2d_93764ee4f484 -->|calls| 389cc9ce_16f8_1d39_88ac_521d7093028a
  style 0d1ab03e_04f2_35e7_7e2d_93764ee4f484 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/config/config.ts lines 133–165

export async function resolveConfig(
	inlineConfig: AstroInlineConfig,
	command: string,
	fsMod = fs,
): Promise<ResolveConfigResult> {
	const root = resolveRoot(inlineConfig.root);
	const { inlineUserConfig, inlineOnlyConfig } = splitInlineConfig(inlineConfig);

	// If the root is specified, assign the resolved path so it takes the highest priority
	if (inlineConfig.root) {
		inlineUserConfig.root = root;
	}

	const userConfig = await loadConfig(root, inlineOnlyConfig.configFile, fsMod);
	const mergedConfig = mergeConfig(userConfig, inlineUserConfig);
	// First-Pass Validation
	let astroConfig: AstroConfig;
	try {
		astroConfig = await validateConfig(mergedConfig, root, command);
	} catch (e) {
		// Improve config zod error messages
		if (e instanceof $ZodError) {
			// Mark this error so the callee can decide to suppress Zod's error if needed.
			// We still want to throw the error to signal an error in validation.
			trackAstroConfigZodError(e);
			console.error(formatConfigErrorMessage(e) + '\n');
			telemetry.record(eventConfigError({ cmd: command, err: e, isFatal: true }));
		}
		throw e;
	}

	return { userConfig: mergedConfig, astroConfig };
}

Domain

Subdomains

Frequently Asked Questions

What does resolveConfig() do?
resolveConfig() is a function in the astro codebase, defined in packages/astro/src/core/config/config.ts.
Where is resolveConfig() defined?
resolveConfig() is defined in packages/astro/src/core/config/config.ts at line 133.
What does resolveConfig() call?
resolveConfig() calls 3 function(s): loadConfig, resolveRoot, splitInlineConfig.

Analyze Your Own Codebase

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

Try Supermodel Free