davies
davies

Reputation: 21

Using external css/js files stored outside the public folder in laravel

I downloaded a laravel source code, and I have been told that the CSS/js files of your application should be stored in the public folder but I noticed that the CSS/js files that the downloaded laravel application used were stored outside the public folder and even outside the entire laravel application folder, and these CSS/js files were accessed within the laravel application. And I also noticed that some of the files that originally comes out of the box with laravel in the public folder were taken out of the public folder and placed outside the application. So my question is,

  1. Is this accepted?
  2. How do I do it?

Upvotes: 0

Views: 608

Answers (1)

ireneo-cobarjr
ireneo-cobarjr

Reputation: 27

Laravels public folder is where your website access files. be it request to API's, CSS, js, html files, images.

It's not a good idea to place your css/js directly into the public folder. Unless you are just doing it for learning purposes or your just doing a fairly simple project.

CSS and JS files that are stored into the public folder should be the compiled and minified versions of it.

You did not clarrified what exactly you are doing. But if that's a fresh laravel install with Vue.js, you should place your css/scss/sass files into /resources/sass folder and js files into /resources/js and let webpack compile it for you. Webpack will be the one to put this compiled versions into the public folder.

Check webpack.mix.js file into your laravel root folder. It should provide you some info on how to compile your assets/css/js files accordingly.

Upvotes: 1

Related Questions