Search code examples
laravelgulplaravel-elixir

Laravel 5 Elixir + gulp mix and version multiple css or less files


I have a separate css/less file for my landing / login page. How do I tell gulp, that it should compile two files for me? Here is my approach which generates unfortunately only one file for me.

elixir(function (mix) {
    // only for the landing-page
    mix.less('landing.less')
        .version('css/landing.css');

    // for the application, after login
    mix.less('app.less')
        .version('css/app.css');
});

On my landing page, I've assumed something like this:

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

but the build/css folder only shows my css/app.css file. :(


Solution

  • You can not call mix.version() twice:

    simply do:

    elixir(function (mix) {
    
        mix.less('landing.less');
    
        // for the application, after login
        mix.less('app.less');
    
        mix.version([
           'css/app.css', 
           'css/landing.css'
        ]);
    
    });
    

    This will generate two files app.css and landing.css for you in /public/build/css