Reputation: 75
I have css under App/resources/css by default
when I open Login and Register page css is not loading. This is default css and js link on my app.blade.php
<script src="{{ asset('js/app.js') }}" defer></script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
I did this
<link href="{{ URL::asset('assets/css/a.css') }}" rel="stylesheet">
and also tried
<script src="{{ asset('resources/js/app.js') }}" defer></script>
<link href="{{ asset('resources/css/app.css') }}" rel="stylesheet">
What shall I do to make it work.??
Upvotes: 5
Views: 33776
Reputation: 2137
Move all your CSS and JavaScript to the public folder so that your structure becomes something like
public/
|--- css/
|---js/
Now to use your CSS and JavaScript from your new location do something like
<script src="{{ asset('js/app.js') }}" defer></script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
This works because the asset()
blade helper already looks from the public directory so you start your CSS and JavaScript URL construction from that point on
Upvotes: 3
Reputation: 5164
I would recommend to always use the mix
helper in Blade like this
<script src="{{ mix('/js/app.js') }}"></script>
as it additionally properly takes care of versioned assets. Please make sure you either ran npm run dev
or npm run prod
(see Compiling assets) to generate the public/css/app.css
and public/js/app.js
files from the ones located in resources
.
Upvotes: 2