Search code examples
cssexceptionlaravel-5sasslaravel-elixir

ErrorException when using Laravel's elixir to import a CSS file


I'm following a Laracast tutorial, episode 6, and I reached the part where the instructor uses <link rel="stylesheet" href="{{ elixir('css/app.css') }}"/> too call the CSS file, but whenever I do this, the following error is thrown:

ErrorException in helpers.php line 341:

file_get_contents(/home/gabriel/Documents/Rxe/public/build/rev-manifest.json): failed to open stream: No such file or directory (View: /home/gabriel/Documents/Rxe/resources/views/admin/layout.blade.php) (View: /home/gabriel/Documents/Rxe/resources/views/admin/layout.blade.php)

I've followed everything from the beginning, but I'm stuck at it.


Solution

  • I had the same problem, posted it on the Laracasts forum and the user Moharrum responded with this fix:

     var elixir = require('laravel-elixir');
    
        elixir(function(mix) {
            mix.sass('app.scss')
                .version([
                    'public/css/app.css'
                ]);
        });
    

    It works because when you use elixir helper to reference the asset, it searches the latest version of the file, so you have to include the version tag to make it available.

    https://laracasts.com/discuss/channels/elixir/elixir-gulp-rev-manifestjson-not-generated