Search code examples
laravellaravel-elixir

styles stop working after adding version to elixir


In Laravel, I’ve in public/css/app.css the following:

body { background: "red"; }

It’s linked to my layout like this:

<link rel="stylesheet" href="/css/app.css" media="screen" title="no title" charset="utf-8">

But when I go to the home page, the style isn’t applied to the body. I checked the source and the CSS file is there!

I removed the cache but nothing happened. This problem start after I added version() to elixir but after that I removed all the build folder, now I can’t get the style working.


Solution

  • When you use version() in elixir the filename changes. You can add following helper

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

    this will always return the correct file name.

    Refer to the documentation for versioning and cache busting.

    Also make sure you run the gulp command again since you deleted the build folder.