Search code examples
laravelgulplaravel-elixir

How to automatically remove compiled styles after they're versioned in Elixir?


I use Laravel Elixir to merge and minify stylesheets. The problem is when I use versioning, it creates two identical copies:

#1

public/build/css/layout.css.map
public/build/css/layout-b94a608888.css

#2

public/css/layout.css
public/css/layout.css.map

How do I remove #2 copy automatically using Gulp?


Solution

  • This question was already asked here: Delete intermediary files after elixir merge

    They recommend using npm del library and the code looks like this:

    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' ]);
    });