astroanu's avatar

Can Elixir version be run only on production?

I want Elixir to run minification and version only on gulp --production. Is this even possible on the current version?. Thanks

0 likes
3 replies
deshiknaves's avatar

You can do this quite easily by checking mix.production

if (mix.production) {
        mix.version([
            'public/assets/css/screen.css'
        ]);
    }
Shovels's avatar

Thanks to @deshiknaves for his answer. Although I couldn't get it to work it did help me in finding a similar alternative which does appear to be working as expected:

in your gulpfile.js wrap anything you want to run ONLY to run in production mode with:

elixir(function (mix) {
    // ... the rest of your gulpfile config

    if (elixir.config.production) {
        mix.version([
            'js/main.js',
            'css/main.css'
        ]);
    } else {
        // Anything you only want to run in non-production mode, e.g. BrowserSync
        mix.browserSync(); 
   }
}
5 likes

Please or to participate in this conversation.