Lloyd Banks
Lloyd Banks

Reputation: 36638

Laravel 5 - Loading Public JS / CSS / HTML Files From Custom Folder?

Laravel serves client side (HTML, CSS, JS) files from the /public folder by default. I am currently transitioning a Blade based front-end to an Angular based one. As a result, I am mixing Blade templating with Angular templating. I am using Blade layouts to generate a navbar, footer, and other common views while I transition the body content of my pages to Angular.

I have a folder constructed just for storing Angular files. My current app structure looks something like this:

-MyApplication
    -angular
    -app
    -bin
    -bootstrap
    -config
    -database
    ....

Is there anyway for Laravel to load my assets - stored in the /angular folder? I want to keep all my Angular files in one place, in standard Angular structure, as opposed to spreading them out and placing them in the /public Laravel folder.

Upvotes: 2

Views: 449

Answers (1)

Risan Bagja Pradana
Risan Bagja Pradana

Reputation: 4674

You can try to create a symbolic link inside the public directory to your intended angular directory. Open your terminal and create a symbolic link like so:

ln -sfv ~/path/to/MyApplication/angular ~/path/to/MyApplication/public/angular

Don't forget to update the ~/path/to/MyApplication to your actual Laravel directory. Now you may refer to the javascript file inside the angular directory like this on your blade template:

<script src="{{ asset('angular/app.js') }}"></script>

Hope this help!

Upvotes: 0

Related Questions