Delete intermediary files after elixir merge

為{幸葍}努か 提交于 2019-12-21 19:44:03

问题


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?


回答1:


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!




回答2:


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


来源:https://stackoverflow.com/questions/29672474/delete-intermediary-files-after-elixir-merge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!