OzzDev's avatar

Do you know why mix('css/app.css') doesn't work?

I'm using tailwindcss and in the welcome.blade.php using this:

        <link rel="stylesheet" href="{{ mix('css/app.css') }}">

The tailwindcss is not working.

However with the asset helper function it works:

    <link rel="stylesheet" href="{{asset('css/app.css') }}">

In the source code with the mix() shows:

404 Not Found

Not Found

The requested URL /css/app.css was not found on this server.

Do you know why with the mix helper does not work? Thanks!

0 likes
11 replies
lbecket's avatar

Did you compile your assets by running npm run dev?

OzzDev's avatar

@lbecket yes, and with {{asset('css/app.css') }} it works fine its loading the tailwindcss styles, however with {{mix('css/app.css') }} the tailwindcss are not loaded and it shows that 404 on the source code. Thanks!

Sinnbeck's avatar

@oscarg try adding a slash before css. As far as I remember it tries to match with the keys in mix-manifest

<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
OzzDev's avatar

@lbecket It seems that the issue is because with mix() the link element becomes like this:

   <link rel="stylesheet" href="/css/app.css">

And with asset() becomes the full path:

    <link rel="stylesheet" href="http://localhost/project/public/css/app.css">

So do you know if with mix() we cannot only use {{ mix('css/app.css') }}? We need to give the path before 'css/app.css'?

OzzDev's avatar

@Sinnbeck no, your with suggestion the produced href its also like this:

  <link rel="stylesheet" href="/css/app.css">

And the tailwindcss styles are not loaded. And in the source code shows:

							<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
404 Not Found

Not Found

The requested URL /css/app.css was not found on this server.

Thanks!

Sinnbeck's avatar

@oscarg in your public directory, do you have a folder called css and inside it app.css?

Sinnbeck's avatar

@oscarg just noticed. Does your website have /public in the url? It shouldn't!

The root url should just be http://localhost

How are you running your dev environment?

1 like
OzzDev's avatar

@Sinnbeck yes, have /public in the url. I'm in dev environment and I'm using laragon. However to create the project I ran the command "laravel new project". I don't know if there is some issue with the dev environment using laragon. I also noticed other issue besides the mix() helper function, for example I can't access the app like "http://project.test/" I need to access like "http://localhost/project/public/".

So maybe this is why I'm getting those issues, do you know how can I fix the dev enviornment to be able to use the mix(), and also access the projet with "http://project.test/"? Thanks!!

Sinnbeck's avatar

@oscarg sadly I don't use laragon, but perhaps create a new thread about the actual issue, which is that laragon does not work as expected Once that gets fixed, laravel mix will also start working

Please or to participate in this conversation.