Laravel 8 asset helpers not working in my new project

Viewed 1436

so I created a new laravel project and use npm run dev to generate my css file inside public folder. like my last project i tried to load my CSS like this

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

but that doesn't work. my folder structure is like this

public
  css
   app.css

I checked a lot of posts but non of them worked. the only way to load the file is like this

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

or

<link href="/css/app.css" rel="stylesheet" type="text/css" >

my question is why asset helper don't work ?

i tried changing the url, changing env 'ASSET_URL', etc

I know this is a really elementary issue, but this question are making me crazy, btw my last project laravel version was 7 but this one version is 8

1 Answers

Use proper path in laravel asset() helper function. asset() helper function access from app/public directory.

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

Related