Home / Function/ shouldRestartContainer() — astro Function Reference

shouldRestartContainer() — astro Function Reference

Architecture documentation for the shouldRestartContainer() function in restart.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  80f04150_5630_d8fd_3766_b57f20410084["shouldRestartContainer()"]
  2daba797_7568_42ad_0193_df1cabafb75a["restart.ts"]
  80f04150_5630_d8fd_3766_b57f20410084 -->|defined in| 2daba797_7568_42ad_0193_df1cabafb75a
  b10fb170_5a7e_6ebe_40a5_6958fe60be52["createContainerWithAutomaticRestart()"]
  b10fb170_5a7e_6ebe_40a5_6958fe60be52 -->|calls| 80f04150_5630_d8fd_3766_b57f20410084
  style 80f04150_5630_d8fd_3766_b57f20410084 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/dev/restart.ts lines 39–73

function shouldRestartContainer(
	{ settings, inlineConfig, restartInFlight }: Container,
	changedFile: string,
): boolean {
	if (restartInFlight) return false;

	let shouldRestart = false;
	const normalizedChangedFile = vite.normalizePath(changedFile);

	// If the config file changed, reload the config and restart the server.
	if (inlineConfig.configFile) {
		shouldRestart = vite.normalizePath(inlineConfig.configFile) === normalizedChangedFile;
	}
	// Otherwise, watch for any astro.config.* file changes in project root
	else {
		shouldRestart = configRE.test(normalizedChangedFile);
		const settingsPath = vite.normalizePath(
			fileURLToPath(new URL(SETTINGS_FILE, settings.dotAstroDir)),
		);
		if (settingsPath.endsWith(normalizedChangedFile)) {
			shouldRestart = settings.preferences.ignoreNextPreferenceReload ? false : true;

			settings.preferences.ignoreNextPreferenceReload = false;
		}
	}

	if (!shouldRestart && settings.watchFiles.length > 0) {
		// If the config file didn't change, check if any of the watched files changed.
		shouldRestart = settings.watchFiles.some(
			(path) => vite.normalizePath(path) === vite.normalizePath(changedFile),
		);
	}

	return shouldRestart;
}

Domain

Subdomains

Frequently Asked Questions

What does shouldRestartContainer() do?
shouldRestartContainer() is a function in the astro codebase, defined in packages/astro/src/core/dev/restart.ts.
Where is shouldRestartContainer() defined?
shouldRestartContainer() is defined in packages/astro/src/core/dev/restart.ts at line 39.
What calls shouldRestartContainer()?
shouldRestartContainer() is called by 1 function(s): createContainerWithAutomaticRestart.

Analyze Your Own Codebase

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

Try Supermodel Free