Search code examples
laravelgulplaravel-5.3laravel-elixir

using elixir mix.version() in Laravel causes view to fail


I'm a new in Laravel and am trying to use the mix.version() in the Gulpfile.js in Laravel 5.3 for cache busting.

this is my gulpfile.js:

    elixir(function (mix){
    mix.less('custom.less');
    mix.version('public/css/custom.css');
    });

When running gulp command in my terminal, my less is compiled and versioned correctly, but when I try to include the the following line my view file, it breaks my view:

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

screenshot of my error

Is there a specific include or something I need to call in my view file to ensure the above line of code actually works? If I remove the above elixir line in my view code and hard code link my css file, then it works, but I can't leave it like that as I need versioning for cache busting.

Thanks so much, I have tried the documentation, but not examples exist of how to include the code in the view file.


Solution

  • There is a ' missing

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

    should be

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

    Regarding the question title

    {{ elixir('/css/custom.css) }}
    

    is causing the error not the mix.version()