Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete intermediary files after elixir merge

I am using Laravel 5. During gulp task, the processed SASS files and other CSS files copied from resource folder are stored in public/css. Then all the files in the public/css are merged together to a single file as "all.css". So the files that were created needs to be deleted.

How can I do this?

like image 435
Dipendra Gurung Avatar asked Dec 19 '22 05:12

Dipendra Gurung


2 Answers

For newer versions of laravel this worked for me:

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

elixir.extend('remove', function(path) {
    new elixir.Task('remove', function() {
        del(path);
    });
});

elixir(function(mix) {
    mix.remove([ 'public/css', 'public/js' ]);
});

Cheers!

like image 51
marcostvz Avatar answered Mar 27 '23 15:03

marcostvz


It was well explained here , anyway just in case it is a broken link, this is what I do and works perfectly. Basically you have to extend gulp and add a "remove" function which uses "del", your last task is just removing the intermediate files once the versioning is finished.

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

elixir.extend("remove", function(path) {
    gulp.task("remove", function() {
        del(path);
    });
    return this.queueTask("remove");
});

// Usage
elixir(function(mix) {
    mix.remove([ 'public/css', 'public/js' ]);
});

You will probably need to install some npm pagackes like so:

$ npm install --save-dev del
$ npm install --save-dev wrappy
$ npm install --save-dev brace-expansion
like image 21
jhmilan Avatar answered Mar 27 '23 14:03

jhmilan