Search code examples
laravel-elixir

Laravel Elixir - Execute cmd on watch update


I'm trying to create an easy workflow for package development and was hoping someone could pint me in the right direction. In short, once a css file has been updated I want to be able to run a command (php artisan vendor:publish --force) to automatically publish the files.

Can this be done with Elixir and if so could anyone point me in the right direction?

regards


Solution

  • if anyone is looking, this works nicely:

    var gulp = require("gulp");
    var shell = require("gulp-shell");
    var elixir = require("laravel-elixir");
    
    elixir.extend("publish", function() {
        var baseDir = this.assetsDir;
        gulp.task("publish_assets", function() {
            gulp.src("").pipe( shell( [
                "php ../../../artisan vendor:publish --force",
                "cd ../../../ ; gulp"
            ]));
        });
        this.registerWatcher("publish_assets", [
            baseDir + '**/*.scss',
            baseDir + '**/*.js'
        ]);
        return this.queueTask("publish_assets");
    });