How to install bootstrap in laravel 8

Issue

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?

Solution

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">

Answered By – Maksim

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.