HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/quadcode-site/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js
let Log = require('../Log');
let collect = require('collect.js');

class CustomTasksPlugin {
    /**
     * Apply the plugin.
     *
     * @param {Object} compiler
     */
    apply(compiler) {
        compiler.hooks.done.tapAsync(
            this.constructor.name,
            (stats, callback) => {
                this.runTasks(stats).then(() => {
                    if (Mix.components.get('version')) {
                        this.applyVersioning();
                    }

                    if (Mix.inProduction()) {
                        this.minifyAssets();
                    }

                    if (Mix.isWatching()) {
                        Mix.tasks.forEach(task => task.watch(Mix.isPolling()));
                    }

                    Mix.manifest.refresh();
                    callback();
                });
            }
        );
    }

    /**
     * Execute the task.
     *
     * @param {Task} task
     */
    runTask(task, stats) {
        return Promise.resolve(task.run()).then(() => {
            task.assets.forEach(asset => {
                Mix.manifest.add(asset.pathFromPublic());

                // Update the Webpack assets list for better terminal output.
                stats.compilation.assets[asset.pathFromPublic()] = {
                    size: () => asset.size(),
                    emitted: true
                };
            });
        });
    }

    /**
     * Execute potentially asynchrone tasks sequentially.
     *
     * @param {Array} tasks
     */
    runTasks(stats, index = 0) {
        if (index === Mix.tasks.length) return Promise.resolve();

        const task = Mix.tasks[index];

        return this.runTask(task, stats).then(() =>
            this.runTasks(stats, index + 1)
        );
    }

    /**
     * Minify the given asset file.
     */
    minifyAssets() {
        collect(Mix.tasks)
            .where('constructor.name', '!==', 'VersionFilesTask')
            .where('constructor.name', '!==', 'CopyFilesTask')
            .each(({ assets }) =>
                assets.forEach(asset => {
                    try {
                        asset.minify();
                    } catch (e) {
                        Log.error(
                            `Whoops! We had trouble minifying "${asset.relativePath()}". ` +
                                `Perhaps you need to use mix.babel() instead?`
                        );

                        throw e;
                    }
                })
            );
    }

    /**
     * Version all files that are present in the manifest.
     */
    applyVersioning() {
        collect(Mix.manifest.get()).each((value, key) =>
            Mix.manifest.hash(key)
        );
    }
}

module.exports = CustomTasksPlugin;