Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install bootstrap in laravel 8

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?

like image 425
MrSandyWilly Avatar asked Dec 02 '22 09:12

MrSandyWilly


2 Answers

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">
like image 167
Maksim Avatar answered Dec 04 '22 21:12

Maksim


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
like image 22
Cleverson Franco Avatar answered Dec 04 '22 21:12

Cleverson Franco