LeTadas
LeTadas

Reputation: 3556

Installing Bootstrap through NPM in Laravel install

I added Bootstrap in my package.json file like this "bootstrap": "^4.3.1" after that I typed npm install in the terminal and it completed without any errors. What's next? How can I add Bootstrap in my view? It seems that NPM installed Bootstrap to the /node_modules folder, but I also have the bootstrap.js file in resources/js/bootstrap.js.

Upvotes: 1

Views: 5929

Answers (1)

Chamara Abeysekara
Chamara Abeysekara

Reputation: 1322

you can use Laravel mix to the compile your assets and then simply link that in your layout, so what you need to is import bootstrap in your app.scss you can do it like this,

@import '~bootstrap/scss/bootstrap';

and in you resources/views/layouts/app.blade.php link that style file like this,

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

in laravel 5.6 or lesser versions app.scssfile was located in resources/assets/sass but in laravel 5.7 and higher version it has been changed to resources/sass/. run npm run dev in your project folder to generate the assets. hope this helps

Upvotes: 9

Related Questions