Akshay Lokur
Akshay Lokur

Reputation: 7516

How to get bootstrap-select css into Laravel public folder

I installed bootstrap-select package using npm. I can see that in node-modules dir of my Laravel project.

I have added following entry to master.blade.php:

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

However when I run php artisan serve on my local machine, and go to browser I can see following error in the console:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (bootstrap-select.css, line 0) http://127.0.0.1:8000/css/bootstrap-select.css

I am using Laravel Framework 5.7.28

Any clues much appreciated!

Upvotes: 2

Views: 1258

Answers (1)

Script47
Script47

Reputation: 14550

As per this comment, you need to link the CSS file in your app.scss using the following syntax:

@import "~module-name/path/to/css.css";

then fire npm run dev which should compile your assets again. Also:

The tilde (~) tells Webpack that we're not looking for that jquery.filer.css file relatively to app.scss. Instead, we want to look within node_modules.

It will compile everything into a single app.css file which you can then include, no need to individually load the bootstrap-select.css file.

Upvotes: 2

Related Questions