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

Pixelkode's avatar

Laravel Elixir depending on environment

It is possible to say Laravel Elixir it has to use different extensions depending the environment?

In the local environment I want to start the BrowserSync-extension, but on the production server (forge-managed) I don't want to execute the BrowserSync task. This would start an process which I have to kill manually via ssh-login...after every deploy :(

0 likes
1 reply
pedroborges's avatar

The docs recommends that you use the production flag when running Gulp in production: gulp --production.

Internally, Elixir defines the variable below to check the environment and modify the behaviour of certain recipes:

var inProduction = elixir.config.production;

You could add the above line to your Gulpfile and do the check yourself.

var elixir = require('laravel-elixir');

var inProduction = elixir.config.production;

elixir(function(mix) {
    mix.sass("bootstrap.scss");

    if (! inProduction) {
        // Do the BrowserSync stuff…
    }
});

I haven't tested this myself, so please let me know if it works.

6 likes

Please or to participate in this conversation.