@@ -425,21 +425,26 @@ export function resolveNestedFilePath(
425425 const normalizedFilePath = filePath . replace ( / ^ \/ | \/ $ / g, '' )
426426 const normalizedCommonRoot = commonRoot . replace ( / ^ \/ | \/ $ / g, '' )
427427
428- // Get component alias without @ prefix and normalize
429- const componentAlias = config . aliases . components . replace ( / ^ @ \/ / , '' ) . replace ( / ^ \/ | \/ $ / g, '' )
430-
431- // Check if the common root contains the component alias
432- if ( normalizedCommonRoot . includes ( componentAlias ) ) {
433- // Find where the component alias ends in the file path
434- const aliasEndIndex = normalizedFilePath . indexOf ( componentAlias ) + componentAlias . length
435-
436- // Return everything after the alias (skip the leading slash if present)
437- // Example: "components/ai-elements/artifact/Artifact.vue" -> "ai-elements/artifact/Artifact.vue"
438- // Example: "src/ui/design-system/button/Button.vue" -> "design-system/button/Button.vue"
439- return normalizedFilePath . substring ( aliasEndIndex ) . replace ( / ^ \/ / , '' )
428+ // Get all aliases without @ prefix and normalize
429+ const aliases = Object . values ( config . aliases )
430+ . map ( alias => alias . replace ( / ^ @ \/ / , '' ) . replace ( / ^ \/ | \/ $ / g, '' ) )
431+ . sort ( ( a , b ) => b . length - a . length ) // Sort by length descending to match most specific first
432+
433+ // Check if the common root contains any of the aliases
434+ for ( const alias of aliases ) {
435+ if ( normalizedCommonRoot . includes ( alias ) ) {
436+ // Find where the alias ends in the file path
437+ const aliasEndIndex = normalizedFilePath . indexOf ( alias ) + alias . length
438+
439+ // Return everything after the alias (skip the leading slash if present)
440+ // Example: "components/ai-elements/artifact/Artifact.vue" -> "ai-elements/artifact/Artifact.vue"
441+ // Example: "lib/utils/cn.ts" -> "utils/cn.ts"
442+ // Example: "composables/useCounter.ts" -> "useCounter.ts"
443+ return normalizedFilePath . substring ( aliasEndIndex ) . replace ( / ^ \/ / , '' )
444+ }
440445 }
441446
442- // Fallback to original logic for non-component paths
447+ // Fallback to original logic for non-aliased paths
443448 // Example: "registry/new-york-v4/ui/button/Button.vue" -> "button/Button.vue"
444449 const lastCommonRootSegment = normalizedCommonRoot . split ( '/' ) . pop ( )
445450
0 commit comments