我怎样才能加快 gulp?

How can I speed up gulp?

在 vanilla Laravel Spark 安装中,我需要大约 20 秒才能 运行 gulp。这是我的日志:

[15:05:48] Starting 'all'...

[15:05:48] Starting 'less'...

[15:05:53] Finished 'less' after 4.74 s

[15:05:53] Starting 'webpack'...

[15:05:58]

[15:05:58] Finished 'webpack' after 5.28 s

[15:05:58] Starting 'copy'...

[15:05:59] Finished 'copy' after 486 ms

[15:05:59] Starting 'copy'...

[15:05:59] Finished 'copy' after 17 ms

[15:05:59] Starting 'less'...

[15:05:59] Finished 'less' after 159 ms

[15:05:59] Starting 'version'...

[15:05:59] Finished 'version' after 517 ms

[15:05:59] Finished 'all' after 11 s

[15:05:59] Starting 'default'...

我的gulp文件:

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

require('laravel-elixir-vue-2');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(function (mix) {
    mix.less('app.less')
        .webpack('app.js', null, null, {
            resolve: {
                modules: [
                    path.resolve(__dirname, 'vendor/laravel/spark/resources/assets/js'),
                    'node_modules'
                ]
            }
        })
        .copy('node_modules/sweetalert/dist/sweetalert.min.js', 'public/js/sweetalert.min.js')
        .copy('node_modules/sweetalert/dist/sweetalert.css', 'public/css/sweetalert.css');

    mix.less('/brand/brand.less');
    
    mix.version(['css/brand.css', 'css/app.css', 'js/app.js']);

我在 Mac Mini 运行ning 代客上使用最新版本的 gulp 和 gulp CLI。我该怎么做才能使 运行 更快? 20 秒似乎过长。

您可以尝试的一件事是停用 sourcemaps 生成:

elixir.config.sourcemaps = false;

其次,您可以在开发模式下停用版本控制,您的应用应该可以正常工作,无需任何更改:

if (elixir.config.production) {
  mix.version(['css/brand.css', 'css/app.css', 'js/app.js']);
}