All of the info I can find online says that you should install bootstrap by running composer require laravel/ui
and then php artisan ui boostrap
. However, in Laravel 8, laravel/ui
is deprecated. Is there a new/better way of installing bootstrap?
You can install bootstrap manually and compile sass.
First, add it to npm with compilers:
npm install bootstrap
npm install sass
npm install sass-loader
Second, create (if not created) resources/sass/app.scss and add this:
@import '~bootstrap';
Third, add compilation in webpack.mix.js:
mix.sass('resources/sass/app.scss', 'public/css')
Than, compile it with npm run dev - you see compiled file public/css/app.css
Now you can use it in templates with asset:
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
The way I do it is similar to what you mention, even in Laravel 8. So I believe you are on the right path.
You can create a new Laravel project using this comand
composer create-project laravel/laravel --prefer-dist laravel-bootstrap
after, in laravel folder run
composer require laravel/ui
If you just want to add bootstrap to an existing project, just run:
php artisan ui bootstrap
npm install
npm run dev
And if you need Auth
php artisan ui bootstrap --auth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With