diff --git a/packages/panels/src/Commands/MakeThemeCommand.php b/packages/panels/src/Commands/MakeThemeCommand.php index 2b103a998f..cb4937e5ff 100644 --- a/packages/panels/src/Commands/MakeThemeCommand.php +++ b/packages/panels/src/Commands/MakeThemeCommand.php @@ -25,12 +25,9 @@ class MakeThemeCommand extends Command { $packageJson = file_get_contents(base_path('package.json')) ?: ''; - $isTailwindV4Installed = str_contains($packageJson, '"@tailwindcss/postcss": "^4') - || str_contains($packageJson, '"@tailwindcss/postcss": "4') - || str_contains($packageJson, '"@tailwindcss/vite": "^4') - || str_contains($packageJson, '"@tailwindcss/vite": "4') - || str_contains($packageJson, '"tailwindcss": "^4') - || str_contains($packageJson, '"tailwindcss": "4'); + $shouldInstallTailwindV3 = str_contains($packageJson, '"tailwindcss": "^3') + || str_contains($packageJson, '"tailwindcss": "3') + || (! str_contains($packageJson, '"tailwindcss": "')); $pm = $this->option('pm') ?? 'npm'; @@ -49,7 +46,7 @@ class MakeThemeCommand extends Command default => "{$pm} install", }; - if (! $isTailwindV4Installed) { + if ($shouldInstallTailwindV3) { exec("{$installCommand} tailwindcss@3 @tailwindcss/forms @tailwindcss/typography postcss postcss-nesting autoprefixer --save-dev"); } else { exec("{$installCommand} @tailwindcss/forms @tailwindcss/typography --save-dev"); @@ -96,7 +93,7 @@ class MakeThemeCommand extends Command ->map(fn ($segment) => Str::lower(Str::kebab($segment))) ->implode('/'); - $this->copyStubToApp($isTailwindV4Installed ? 'ThemeCssTailwind4' : 'ThemeCss', $cssFilePath, [ + $this->copyStubToApp($shouldInstallTailwindV3 ? 'ThemeCss' : 'ThemeCssTailwind4', $cssFilePath, [ 'panel' => $panelId, ]); $this->copyStubToApp('ThemeTailwindConfig', $tailwindConfigFilePath, [ @@ -106,7 +103,7 @@ class MakeThemeCommand extends Command $this->components->info("Filament theme [resources/css/filament/{$panelId}/theme.css] and [resources/css/filament/{$panelId}/tailwind.config.js] created successfully."); - if ($isTailwindV4Installed) { + if (! $shouldInstallTailwindV3) { $this->components->warn('Action is required to complete the theme setup:'); $this->components->bulletList([ 'It looks like you have Tailwind v4 installed. Filament uses Tailwind v3. You should downgrade your project and re-run this command with `--force`, or use the following command to compile the theme with the Tailwind v3 CLI:',