删除 Laravel 混合中的临时文件

Delete Temp Files in Laravel Mix

我想在 laravel-mix 构建期间或之后删除临时构建文件。
这是我目前拥有的一些代码,但 del 不起作用:

const mix = require('laravel-mix');
const del = require('del');

// compile sass into temp css file
mix.sass('resources/stylesheets/style.scss', 'public/css/temp.css');

// compile css
mix.styles([
    // other css stylesheets here...
    'public/css/temp.css' // include temp css file
], 'public/css/admin.min.css');

// delete temp css file
del('public/css/temp.css'); // not deleting the file

我能够通过 运行 delmix.styles() 返回的 then() 中解决这个问题:

const mix = require('laravel-mix');
const del = require('del');

// compile sass into temp css file
mix.sass('resources/stylesheets/style.scss', 'public/css/temp.css');

// compile css
mix.styles([
    // other css stylesheets here...
    'public/css/temp.css' // include temp css file
], 'public/css/admin.min.css').then(() => {
    del('public/css/temp.css'); // deletes the temp file
});

同样的事情也适用于 mix.scripts():

mix.scripts([
    'public/js/app.js',
    'public/js/global.js',
], 'public/js/app.combined.js').then(() => {
    del('public/js/app.js');
    del('public/js/global.js');
});