Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,19 +769,15 @@ private static function detectComponentName(string $basePath): string
if (\count($pathParts) >= self::MIN_PATH_PARTS_FOR_DETECTION) {
$parentDir = $pathParts[\count($pathParts) - 2];

// For themes, consider parent/child theme scenarios
if ('themes' === $parentDir) {
if (str_ends_with($lastPart, '-child')) {
// Handle WordPress component directories
if (\in_array($parentDir, ['themes', 'plugins', 'mu-plugins'], true)) {
// Special case for child themes
if ('themes' === $parentDir && str_ends_with($lastPart, '-child')) {
$lastPart = preg_replace('/-child$/', '', $lastPart) ?? $lastPart;
}

return preg_replace('/[^a-zA-Z0-9]/', '-', $lastPart) ?? $lastPart;
}

// For plugins, use the plugin directory name
if ('plugins' === $parentDir) {
return preg_replace('/[^a-zA-Z0-9]/', '-', $lastPart) ?? $lastPart;
}
}

// Fallback: clean the last directory name
Expand Down
Loading