realrashid sweetalert2 not defined or not found
I am trying to use realrashid/sweetalert2 in laravel 12.
I installed the package and in my blade I have this code:
<!DOCTYPE html>
<html lang="en">
<head>
@include('layouts.meta')
<title>Home | {{ config('app.name') }}</title>
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head>
<body data-bs-spy="scroll" data-bs-target="#navbarNav" data-bs-offset="80" tabindex="0">
... some html...
@include('sweetalert::alert')
<script src="https://kit.fontawesome.com/5fb9c0ddb1.js" crossorigin="anonymous"></script>
<script src="https://snapwidget.com/js/snapwidget.js"></script>
</body>
In my app.js:
import './bootstrap';
import Swal from 'sweetalert2'
window.Swal = Swal
I get the error:
GET http://highlandnew.local/vendor/sweetalert/sweetalert.all.js [HTTP/1.1 404 Not Found 136ms]
Uncaught ReferenceError: Swal is not defined
I looked at: vendor/realrashid/sweet-alert/resources/views/alert.blade.php it has this line:
<script src="{{ $cdn ?? asset('vendor/sweetalert/sweetalert.all.js') }}"></script>
There is no folder vendor/sweetalert, there is folder: vendor/realrashid/sweet-alert...
So I published the package assets, and now I have:
resources\views\vendor\sweetalert\alert.blade.php and public\vendor\sweetalert\sweetalert.all.js
but now, this line:
@include('sweetalert::alert')
does not include the alert view in the blade, and of course I'm getting the Swal not defined error again.
What am I missing?
Please or to participate in this conversation.