Home / Function/ resolveConfigPaths() — ui Function Reference

resolveConfigPaths() — ui Function Reference

Architecture documentation for the resolveConfigPaths() function in get-config.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  b2c37284_9293_dd2f_f854_08ac035b9dfd["resolveConfigPaths()"]
  913f04e7_90de_d0b5_5068_4dacd40de96e["get-config.ts"]
  b2c37284_9293_dd2f_f854_08ac035b9dfd -->|defined in| 913f04e7_90de_d0b5_5068_4dacd40de96e
  accda39a_0dd0_5dea_eb7b_df6ae4616716["getConfig()"]
  accda39a_0dd0_5dea_eb7b_df6ae4616716 -->|calls| b2c37284_9293_dd2f_f854_08ac035b9dfd
  style b2c37284_9293_dd2f_f854_08ac035b9dfd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/get-config.ts lines 46–102

export async function resolveConfigPaths(
  cwd: string,
  config: z.infer<typeof rawConfigSchema>
) {
  // Merge built-in registries with user registries
  config.registries = {
    ...BUILTIN_REGISTRIES,
    ...(config.registries || {}),
  }

  // Read tsconfig.json.
  const tsConfig = await loadConfig(cwd)

  if (tsConfig.resultType === "failed") {
    throw new Error(
      `Failed to load ${config.tsx ? "tsconfig" : "jsconfig"}.json. ${
        tsConfig.message ?? ""
      }`.trim()
    )
  }

  return configSchema.parse({
    ...config,
    resolvedPaths: {
      cwd,
      tailwindConfig: config.tailwind.config
        ? path.resolve(cwd, config.tailwind.config)
        : "",
      tailwindCss: path.resolve(cwd, config.tailwind.css),
      utils: await resolveImport(config.aliases["utils"], tsConfig),
      components: await resolveImport(config.aliases["components"], tsConfig),
      ui: config.aliases["ui"]
        ? await resolveImport(config.aliases["ui"], tsConfig)
        : path.resolve(
            (await resolveImport(config.aliases["components"], tsConfig)) ??
              cwd,
            "ui"
          ),
      // TODO: Make this configurable.
      // For now, we assume the lib and hooks directories are one level up from the components directory.
      lib: config.aliases["lib"]
        ? await resolveImport(config.aliases["lib"], tsConfig)
        : path.resolve(
            (await resolveImport(config.aliases["utils"], tsConfig)) ?? cwd,
            ".."
          ),
      hooks: config.aliases["hooks"]
        ? await resolveImport(config.aliases["hooks"], tsConfig)
        : path.resolve(
            (await resolveImport(config.aliases["components"], tsConfig)) ??
              cwd,
            "..",
            "hooks"
          ),
    },
  })
}

Subdomains

Called By

Frequently Asked Questions

What does resolveConfigPaths() do?
resolveConfigPaths() is a function in the ui codebase, defined in packages/shadcn/src/utils/get-config.ts.
Where is resolveConfigPaths() defined?
resolveConfigPaths() is defined in packages/shadcn/src/utils/get-config.ts at line 46.
What calls resolveConfigPaths()?
resolveConfigPaths() is called by 1 function(s): getConfig.

Analyze Your Own Codebase

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

Try Supermodel Free