Files . css should be in the /public or /Resources folder?

Asked

Viewed 400 times

1

I wonder why Laravel 8 is built with the folder /css inside /resources and not within /public, as set out in documentation?

Call from the css file Directory of the css file outworking
<link href="{{ asset('css/main.css') }}" rel="stylesheet" type="text/css"> Resources/css/main.css Laravel cannot find the folder and does not load the css file.
<link href="{{ asset('css/main.css') }}" rel="stylesheet" type="text/css"> public/css/main.css Everything happens perfectly.

2 answers

3

The public directory contains the index.phparquivo, which is the entry point for all requests entering your application and configures automatic loading. This directory also hosts your assets, as images, Javascript and CSS.

The directory Resource contains your views as well as your gross resources and not compiled, such as CSS or Javascript. This directory also contains all your language files.

Your . css files should be ,for example, in an Assets folder within Public.

1

You can also minify your Assets by following Laravel’s own documentation with Laravel Mix. They remain in your Resources folder and will be minified to the public folder.

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css');

Linka for documentation: https://laravel.com/docs/8.x/mix

Browser other questions tagged

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