Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include js file from 'resources' folder (Laravel 5.5)

Tags:

php

laravel-5

I used the following code to include my js file:

Meta::addJs('admin_js', '/resources/assets/admin_js/admin_app.js');

The file exists but in the console I see status 404.

If I move the file to 'public' folder - all ok. But I want that this file be stored in 'resources' directory

like image 224
Viktor Avatar asked Oct 16 '25 06:10

Viktor


1 Answers

  1. you have to move js files to public or store into storage and make symlinks.
  2. or you need to create symlinks the resources directory to a public directory(which is not recommended).

  3. you need to use the most recommended and effective method of Laravel of using Laravel mix. Please use the link below to read about laravel mix a solution.

https://laravel.com/docs/5.6/mix

It will allow you to place your js assets into resources directory and make compressed js file in public which will be used by the setup.

like image 64
Prashant Barve Avatar answered Oct 17 '25 19:10

Prashant Barve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!