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

georgeboot's avatar

Elixir best practices: run on every deploy?

First of all, I use Elixir with a lot of pleasure. Love the automation and simplicity of the tool.

However, I find myself running it on every deploy (using Envoyer). This not only consumes a lot of time (npm install can take up to 5 minutes in my case) but seems also pretty unnecessary. I don't always update any of my assets, but on every deploy my script runs and re-generates all assets.

One could argue I can just run Envoyer locally and commit the assets, but this feels wrong (although that is totally subjective).

What do you guys think are best practises here?

0 likes
4 replies
bashy's avatar

I gulp while I'm modifying files/styles and push the compiled assets... Elixir won't update compiled assets unless something has changed. Why do you do it on the server?

1 like
Will's avatar

I do it locally and commit/push it.

georgeboot's avatar

@bashy Well, to my understanding that's kind of (one of the) the point of a package manager. I use bower to install my assets, and Elixir to combine them and copy all dependencies to the public folder.

If you commit the assets you will again end up with versions of dependencies in your project, and is the ease of updating them the only gain from using a package manager like bower.

lindstrom's avatar

I don't have anything in public under version control. I think this was a lesson I learned the hard way with merge conflicts with versioned files. I still have dependencies I pull in with bower under version control AFTER I copy them to resources/assets and I only copy in development. So yeah, I choose to wait for npm install and gulp --production. Worst case, switch to the previous release in Envoyer (and php artisan migrate:rollback in the worst of cases)

For npm, I use npm shrinkwrap to ensure only those exact versions are installed on production.

FWIW, here's an abbreviated version of my gulpfile:

var elixir = require('laravel-elixir');
var isProduction = elixir.config.production;
elixir.config.sourcemaps = false;
elixir.config.notify = false;
var isProduction = elixir.config.production;

// don't copy dependencies in production
elixir(function(mix) {
    if (! isProduction ) {
        mix.copy('bower_components/bootstrap/scss', 'resources/assets/sass/bootstrap/scss');
        // more dependencies
    }

    mix.sass('app.scss', 'resources/assets/css');

    mix.styles([
        'app.css',
   ], 'public/css/app.css', 'resources/assets/css');

    mix.scripts([
        //  js dependencies
        'app.js',
    ], 'public/js/app.js', 'resources/assets/js');

    mix.version([
        'public/css/app.css',
        'public/js/app.js',
   ]);

    // copy images - have to do this after version
    mix.copy('resources/assets/images', 'public/images');
});

Please or to participate in this conversation.