Home / Function/ rootRelativePath() — astro Function Reference

rootRelativePath() — astro Function Reference

Architecture documentation for the rootRelativePath() function in viteUtils.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  713a662b_6176_88d7_7934_63a0ffe35d12["rootRelativePath()"]
  b7a40933_4ff9_20ad_c87e_be8112bdd644["viteUtils.ts"]
  713a662b_6176_88d7_7934_63a0ffe35d12 -->|defined in| b7a40933_4ff9_20ad_c87e_be8112bdd644
  b7d7daa6_6e47_6026_9d0b_458be9f6257c["normalizePath()"]
  713a662b_6176_88d7_7934_63a0ffe35d12 -->|calls| b7d7daa6_6e47_6026_9d0b_458be9f6257c
  style 713a662b_6176_88d7_7934_63a0ffe35d12 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/viteUtils.ts lines 28–44

export function rootRelativePath(
	root: URL,
	idOrUrl: URL | string,
	shouldPrependForwardSlash = true,
) {
	let id: string;
	if (typeof idOrUrl !== 'string') {
		id = unwrapId(viteID(idOrUrl));
	} else {
		id = idOrUrl;
	}
	const normalizedRoot = normalizePath(fileURLToPath(root));
	if (id.startsWith(normalizedRoot)) {
		id = id.slice(normalizedRoot.length);
	}
	return shouldPrependForwardSlash ? prependForwardSlash(id) : id;
}

Domain

Subdomains

Frequently Asked Questions

What does rootRelativePath() do?
rootRelativePath() is a function in the astro codebase, defined in packages/astro/src/core/viteUtils.ts.
Where is rootRelativePath() defined?
rootRelativePath() is defined in packages/astro/src/core/viteUtils.ts at line 28.
What does rootRelativePath() call?
rootRelativePath() calls 1 function(s): normalizePath.

Analyze Your Own Codebase

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

Try Supermodel Free