[Solved] JetStream CSS and JS not working and showing @vite(['resources/css/app.css', 'resources/js/app.js'])
Problem:
on my laravel 8 project I installed livewire ,laravel mix and jetstream. But the
Jetsream's css and js is not working and shows a message in header-
@vite(['resources/css/app.css', 'resources/js/app.js'])
Solution 1:
As per the documentation of Laravel 8 we have to install the laravel breeze using this command.
composer require laravel/breeze --dev
But that command will install the latest version of breeze (^1.10) with Laravel 9 Vite support. But Laravel 8 doesn't support Vite,So you will have to use an older version of laravel breeze. For example version 1.9.4 with Laravel 8.
So try this command to install laravel breeze-
composer require laravel/breeze:1.9.4
Solution 2:
Replace the Welcome.blade.php ,guest.blade.php and test.blade.php with this code-
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
@livewireStyles
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
</head>
<body>
<div class="font-sans text-gray-900 antialiased">
{{ $slot }}
</div>
@livewireScripts
</body>
</html>
Thank you for reading the article. If you face any further problem feel free to contact us.