I already tried it through webpack and I got an error and I did it
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<title>Componentes</title>
<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
@yield('content')
</div>
<script src="{{ asset('js/jquery.js')}}"></script>
<script src="{{ asset('js/app.js')}}"></script>
<script src="{{ asset('js/bootstrap.js')}}"></script>
<script src="{{ asset('js/toastr.js')}}"></script>
</body>
</html>
GET http://sistema.test/js/toastr.js net::ERR_ABORTED 404 (Not Found) dashboard:57 GET http://sistema.test/js/bootstrap.js net::ERR_ABORTED 404 (Not Found) dashboard :55 GET http://sistema.test/js/jquery.js net::ERR_ABORTED 404 (Not Found) app.js:13246 Uncaught Error: Bootstrap's JavaScript requires jQuery at Object../resources/js/bootstrap.js ( app.js:13246) at webpack_require (app.js:20) at Object../resources/js/app.js (app.js:13187) at webpack_require (app.js:20) at Object.0 (app. js:15629) at webpack_require(app.js:20) at app.js:84 at app.js:87 ./resources/js/bootstrap.js @ app.js:13246 webpack_require @ app.js:20 ./resources/js/app.js @ app.js:13187 webpack_require @ app.js:20 0 @ app.js:15629 webpack_require @ app.js:20 (anonymous) @ app.js:84 (anonymous) @ app.js:87 dashboard:57 GET http ://system.test/js/bootstrap.js net::ERR_ABORTED 404 (Not Found) dashboard:58 GET http://system.test/js/toastr.js net::ERR_ABORTED 404 (Not Found)
You can guide yourself as they did in previous versions of Laravel. For example in version 5.6, Laravel by default came with jquery 3.2 and bootstrap 4 if you wanted to use the front-end scaffolding.
The relevant code would be the following:
package.json
In this one, just keep in mind that the versions are already old, for example
laravel-mix
, so you can keep the ones that Laravel 6.x brings and remove what you are not going to use, for the example I will only comment the lines ofvue
andaxios
but you can remove them directly, since the question is aboutjquery
andbootstrap
./resources/assets/js/app.js
/resources/assets/js/bootstrap.js
/resources/assets/sass/app.scss
webpack.mix.js
Having those files, just run the npm commands and everything should work fine.
Finally, in your main view you load the compiled files:
Also this answer can help you understand how to import libraries.