Search code examples
twitter-bootstraplaravel-5gulpbowerlaravel-elixir

How to install bootstrap in Laravel 5 using bower, gulp and elixir?


I added bootstrap-sass-official to my bower dependencies into bower_components.

I compiled and added bootstrap css files to public this way (in gulpfile.js):

var paths = {
    'bootstrap': 'bower_components/bootstrap-sass-official/assets/',
    'jquery':    'bower_components/jquery/dist/'
};


elixir(function(mix) {
    mix.sass('app.scss', null, {includePaths: [paths.bootstrap + 'stylesheets/']});
});

In app.scss there is a line @import '_bootstrap';. And css files are compiled and they work.

How can I add bootstrap fonts and scripts to the page?


Solution

  • I found out a solution:

    mix.scripts(
        '*',
        'resources/assets/javascripts',
        'public/js/app.js'
    );
    mix.scripts(
        [
            paths.jquery + 'jquery.js',
            paths.bootstrap + 'javascripts/bootstrap.js'
        ],
        'public/js/dependencies.js',
        'bower_components'
    );
    mix.copy(paths.bootstrap + 'fonts/bootstrap/', "public/fonts/");