What is the right way to import css and javascript in a project view?

Asked

Viewed 247 times

1

I saw on the internet that puts the files in the public folder and calls in the view the Asset function of Blade... but this is currently correct ? why I see that in the project the js and css files come in the Resources folder... by default... the correct thing would not be to call them from there ?

  • Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativities worth reading the Stack Overflow Survival Guide in English.

1 answer

0


The briefcase public is, as the name says, public, ie, everything it contains is accessible via the url of the server that is running the application. Example if your application is running on localhost on port 80:

SUA_APLICACAO/app/public/img/logo.png

will be available via: http://localhost/img/logo.png.

Now, if you move this same file to the folder resources it will no longer be available at the above url.

Already the folder resources are the files that the front-end source that can be compiled and its results will go to the public.

Not necessarily the function asset() (which is a helper and can be accessed anywhere in the application, not only in Blade) will fetch the files in the public, your files may be elsewhere as in the documentation example: https://laravel.com/docs/master/helpers#method-Asset

Browser other questions tagged

You are not signed in. Login or sign up in order to post.