Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

szainmehdi's avatar

Laravel Elixir - Multiple sets of scripts

Hey guys:

I've started using Laravel 5.0 for a quick project, and I've run into this issue with Laravel Elixir. I'm not sure if I'm doing something wrong here, so any help would be much appreciated.

My Gulpfile.js looks like this:

elixir(function(mix) {
    mix.less(["backend.less", "frontend.less"])
        .scripts(
            [
                'jquery/dist/jquery.min.js',
                'bootstrap/dist/js/bootstrap.min.js',
                'jasny-bootstrap/dist/js/jasny-bootstrap.min.js'
            ],
            'bower_components',
            'public/js/dependencies.min.js'
        )
        .scripts(
            [
                'js/main.js',
                'js/etc.js',
            ],
            'resources/assets',
            'public/js/app.min.js'
        )
        .routes()
        .events()
        .phpUnit();

});

The issue is that only the last scripts call is working. The intended result of this setup is to have an app.min.js file and a dependencies.min.js file created. ONLY the app.min.js is being created.

0 likes
7 replies
JeffreyWay's avatar

Hmm - using the latest version of the Elixir extension ("laravel-elixir": "^0.4.10"), I just tried out this exact code, and it worked.

Can you confirm that your version of Elixir matches that?

1 like
szainmehdi's avatar

That was it, Thanks! My package.json had Elixir automatically set to this:

"devDependencies": {
        "gulp": "^3.8.8",
        "laravel-elixir": "^0.3.5"
}

While you're here, is there a good way to make sure npm pulls in the latest one instead of 0.4.10 or 0.3.5?

Edit Answered my own question. For now, until Laravel 5 is officially released, I'll go ahead and replace the version with "*", resulting in:

"devDependencies": {
        "gulp": "^3.8.8",
        "laravel-elixir": "*"
}

That should pull in the latest version, which is useful for this development period.

Thanks for your help Jeffrey. I wouldn't have thought to check the version of Elixir separately.

wickedsp1d3r's avatar

Another thing that I noticed:

If I have multiple sets of Scripts in my Gulpfile.js and I issue gulp watch, the first set is watched, but not the latter one.

briedis's avatar

I have a similiar issue, where I'm using this on a non-laravel project. I have two public directories - CMS and main web page. I would like to keep files in one source directory, and them compile and move them to needed locations:

Structure is something like this:

Sources:

/resources
    /cms
        /js
        /css
    /www
        /js
        /css

Destinations:

public-cms/
public-www/

I have trouble making it work, because config allows only one public directory.

Please or to participate in this conversation.