Search code examples
twitter-bootstraplaravel-5laravel-elixir

Laravel Elixir: Gulp won't compile Bootstrap Sass files


So I started with Laravel 5, Elixir and Bower and followed the guide published on laravel-news.

I managed to compile all scripts but Gulp won't compile the Bootstrap Sass files even if it says Finished 'sass' after 228 ms. This is what I have in my gulpfile atm:

var paths = {
    'bootstrap': './vendor/bower_components/bootstrap-sass-official/assets/'
}

elixir(function(mix) {
    mix.sass("style.scss", 'public/css/', {includePaths: [paths.bootstrap + 'stylesheets/']})
});

But when I run gulp there is no css directory with the css file in it.
What could the problem be? I really don't know what's the problem.

I'm running on Mac OSX (10.10), MAMP and updated all apps, dependencies etc.
As stated in this stackoverflow post I checked if Elixir is the latest version and it is (* and no specific version).

Is there a way to debug Elixir? I have not found anything about this.


Solution posted in this answer


Solution

  • Solution:
    It wasn't the wrong path but more that I misunderstood the documentation of the function. The includePaths: does not tell Sass to include them into the CSS file. It tells Sass where to look for files that were imported with @import.

    gulpfile.js

    var bower_path = "./vendor/bower_components";
    var paths = {
      'jquery'     : bower_path + "/jquery/dist",
      'bootstrap'  : bower_path + "/bootstrap-sass-official/assets",
      'fontawesome': bower_path + "/fontawesome"
    };
    
    mix.sass("app.scss", "public/assets/css", {
      includePaths: [
        paths.bootstrap + '/stylesheets',
        paths.fontawesome + '/scss'
      ]
    });
    

    resources/assets/sass/app.scss

    @import "bootstrap";
    @import "font-awesome";
    

    With this code I was able to compile a CSS file.

    The complete code can be found at the InvoicePlane repo at Github.