Home > Blockchain >  Why my css file is not loading in laravel?
Why my css file is not loading in laravel?

Time:06-28

I am very new to the laravel , i have done login blade file and i included css files but it's not loading css files ,can you please help me where did i mistake ..?

users.blade.php

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

CodePudding user response:

You're trying to access the resources folder, which is not exposed to the public, you'll have to compile your css so it lives in the public folder, which is the folder that anyone(including your frontend) can access using https://your-url.tld/{public file path}. There are 2 ways in which you can have your user.css file available for to your frontend:

One:

You can import your user.css file to the existing resources/css/app.css file:

/* app.css file */
@import "../path/to/user.css";

Two:

You can compile user.css to a separate file, in case you want to use that file specifically on another layout or blade file instead of mixing it globally with the app.css file:

// webpack.mix.js file
mix.js('...')
    .css('resources/css/user.css', 'public/css');

Then in your layout file:

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

Hope it helps.

  • Related