Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Access css and js file from resources css and js directory

This is my directory structure.

-resources
  -css
    -mycss.css
  -js
    -myjs.js
  -myimagesfolder
  -views
    -admin
      -home.blade.php

how can i access resources>css>mycss.css , resources>js>myjs.js and resources>mymagesfolder>images in my views>admin>home.blade.php.

like image 791
Curious Avatar asked Dec 18 '22 12:12

Curious


2 Answers

Put your css and js file inside public folder like this:

-public
  -css
    -mycss.css
  -js
    -myjs.js

Now you can access your files like this.Putthis below line of code inside head tag

For css

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

For Js

<script src="{{asset('js/myjs.js')}}"></script>
like image 170
Pashupati Sah Avatar answered Feb 06 '23 02:02

Pashupati Sah


According to Laravel official documents link, files under /resources/css, /resources/js need be compiled before use.

like image 21
Chih-Hung Hsieh Avatar answered Feb 06 '23 02:02

Chih-Hung Hsieh