Running mix.version() inside Gulp Task

Posted 3 years ago by elqouent10

I am running a gulp task to copy all files with a .tpl.html recursively within a particular folder to the public folder. These html files will be used by AngularJS as templates. While doing this, I want to add all the file paths with a .tpl.html extension into an array, so that I can cache bust all of them.

var versionedFiles = [];

mix.task('copyHtmlTemplates', 'resources/assets/js/app/**/*.tpl.html');
gulp.task('copyHtmlTemplates', function(){
            .pipe(rename(function (path) {
                var fullPath = 'public/js/app/templates/' + path.dirname + '/' + path.basename + path.extname;
                return path;
            .on('end', function(){
        console.log("triggered"); //THIS SHOWS IN CONSOLE
        mix.version(versionedFiles);               //BUT THIS DOESN'T RUN
                mix.version([ 'public/css/app.css']); //BUT THIS DOESN'T RUN EITHER
        mix.version([ 'alskdflasdkj.css']); //MIX.VERSION DOESN'T WANT TO RUN!!!

mix.version(versionedFiles);    //This runs, but it uses the array BEFORE the gulp task can append to it.

Does anyone know how to get mix.version to run after all gulp tasks have completed?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.