mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #16152 from filamentphp/fix-make-theme-command-to-work-with-tailwind-css-alias
Fix make theme command to work with Tailwind CSS alias
This commit is contained in:
@@ -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:',
|
||||
|
||||
Reference in New Issue
Block a user