4

I'm starting out with Laravel which as at the time of this writing is 6.0. I need to import custom JS and CSS files in my project.

Form the file structure in Laravel 6, there is a js/ and /sass file in the resources folder. I have created a script.js and a style.css file right there. I tried to call them using the code

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

and

    <link href='{{ asset('sass/style.css')}}'>

but my console log shows

    GET http://127.0.0.1:8000/js/app.js net::ERR_ABORTED 404 

Is there a new way of calling these files in Laravel 6.

1 Answer 1

3

Basically the function asset() will look for files in the public folder. Since laravel starts from the public folder.

Create new folders on public as js & sass then move you are files in new folders.

public folder host's assets such as images, JavaScript, and CSS. please check laravel structure for more information.

Having files In resources/js & sass folders should be compiled with laravel mix to public folder, you should try this when you learnt 80% percent of laravel.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. I now understand plus I have tried the laravel mix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.