Skip to content

Commit

Permalink
Replace the npm run dev with tailwind:watch and rename vite to tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Feb 16, 2025
1 parent fa8d454 commit 8d95654
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Console/InstallsTurboStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HotwiredLaravel\TurboBreeze\Console;

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Process;
use Symfony\Component\Finder\Finder;

Expand All @@ -29,28 +30,28 @@ protected function installTurboStack(bool $importmaps = true)
(new Filesystem)->ensureDirectoryExists(resource_path('js/controllers'));
(new Filesystem)->ensureDirectoryExists(resource_path('js/libs'));

(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/turbo/resources/js/', resource_path('js/'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/turbo/resources/js/', resource_path('js/'));

// Controllers
(new Filesystem)->ensureDirectoryExists(app_path('Http'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/turbo/app/Http', app_path('Http'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/turbo/app/Http', app_path('Http'));

// Views...
(new Filesystem)->ensureDirectoryExists(resource_path('views'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/turbo/resources/views', resource_path('views'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/turbo/resources/views', resource_path('views'));

// Views Components...
(new Filesystem)->ensureDirectoryExists(resource_path('views/components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/turbo/resources/views/components', resource_path('views/components'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/turbo/resources/views/components', resource_path('views/components'));

// Views Layouts...
(new Filesystem)->ensureDirectoryExists(resource_path('views/layouts'));
(new Filesystem)->put(resource_path('views/layouts/app.blade.php'), str_replace('{SCRIPTS_PLACEHOLDER}', $this->scriptsContent($importmaps), (new Filesystem)->get(__DIR__.'/../../stubs/turbo/resources/views/layouts/app.blade.php')));
(new Filesystem)->put(resource_path('views/layouts/guest.blade.php'), str_replace('{SCRIPTS_PLACEHOLDER}', $this->scriptsContent($importmaps), (new Filesystem)->get(__DIR__.'/../../stubs/turbo/resources/views/layouts/guest.blade.php')));
(new Filesystem)->put(resource_path('views/layouts/app.blade.php'), str_replace('{SCRIPTS_PLACEHOLDER}', $this->scriptsContent($importmaps), (new Filesystem)->get(__DIR__ . '/../../stubs/turbo/resources/views/layouts/app.blade.php')));
(new Filesystem)->put(resource_path('views/layouts/guest.blade.php'), str_replace('{SCRIPTS_PLACEHOLDER}', $this->scriptsContent($importmaps), (new Filesystem)->get(__DIR__ . '/../../stubs/turbo/resources/views/layouts/guest.blade.php')));

// Components...
(new Filesystem)->ensureDirectoryExists(app_path('View/Components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/turbo/app/View/Components', app_path('View/Components'));
(new Filesystem)->copyDirectory(__DIR__ . '/../../stubs/turbo/app/View/Components', app_path('View/Components'));

// Dark mode...
if (! $this->option('dark')) {
Expand All @@ -62,8 +63,8 @@ protected function installTurboStack(bool $importmaps = true)
}

// Routes...
copy(__DIR__.'/../../stubs/turbo/routes/web.php', base_path('routes/web.php'));
copy(__DIR__.'/../../stubs/turbo/routes/auth.php', base_path('routes/auth.php'));
copy(__DIR__ . '/../../stubs/turbo/routes/web.php', base_path('routes/web.php'));
copy(__DIR__ . '/../../stubs/turbo/routes/auth.php', base_path('routes/auth.php'));

// "Dashboard" Route...
$this->replaceInFile('/home', '/dashboard', resource_path('views/welcome.blade.php'));
Expand All @@ -74,8 +75,8 @@ protected function installTurboStack(bool $importmaps = true)

if (! $importmaps) {
// Vite stuff...
copy(__DIR__.'/../../stubs/turbo/postcss.config.js', base_path('postcss.config.js'));
copy(__DIR__.'/../../stubs/turbo/vite.config.js', base_path('vite.config.js'));
copy(__DIR__ . '/../../stubs/turbo/postcss.config.js', base_path('postcss.config.js'));
copy(__DIR__ . '/../../stubs/turbo/vite.config.js', base_path('vite.config.js'));
} else {
// Install Packages...
Process::forever()->path(base_path())->tty(PHP_OS != 'WINNT' && is_writable('/dev/tty'))->run([$this->phpBinary(), 'artisan', 'importmap:install'], function ($_type, $output) {
Expand All @@ -84,11 +85,14 @@ protected function installTurboStack(bool $importmaps = true)
Process::forever()->path(base_path())->tty(PHP_OS != 'WINNT' && is_writable('/dev/tty'))->run([$this->phpBinary(), 'artisan', 'tailwindcss:install'], function ($_type, $output) {
$this->output->write($output);
});

File::replaceInFile('npm run dev', 'php artisan tailwindcss:watch', base_path('composer.json'));
File::replaceInFile('vite', 'tailwind', base_path('composer.json'));
}

// TailwindCSS...
copy(__DIR__.'/../../stubs/turbo/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__.'/../../stubs/turbo/resources/css/app.css', resource_path('css/app.css'));
copy(__DIR__ . '/../../stubs/turbo/tailwind.config.js', base_path('tailwind.config.js'));
copy(__DIR__ . '/../../stubs/turbo/resources/css/app.css', resource_path('css/app.css'));

Process::forever()->path(base_path())->tty(PHP_OS != 'WINNT' && is_writable('/dev/tty'))->run([$this->phpBinary(), 'artisan', 'turbo:install'], function ($_type, $output) {
$this->output->write($output);
Expand Down

0 comments on commit 8d95654

Please sign in to comment.