MOON
Server: Apache
System: Linux server.royaltuning.hu 4.18.0-425.13.1.el8_7.x86_64 #1 SMP Tue Feb 21 04:20:52 EST 2023 x86_64
User: royaltuning (1001)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //var/www/html/webpack.mix.js
const glob = require("glob");
const mix = require("laravel-mix");
const execSync = require("child_process").execSync;

require("laravel-mix-merge-manifest");

// compile admin and theme assets
let configs = glob.sync(
    "{./Modules/*/webpack.mix.js,./Themes/*/webpack.mix.js}"
);

// compile admin assets only
// let configs = glob.sync("./Modules/*/webpack.mix.js");

// compile theme assets only
// let configs = glob.sync("./Themes/*/webpack.mix.js");

if (process.env.module !== undefined) {
    let module =
        process.env.module.charAt(0).toUpperCase() +
        process.env.module.slice(1);

    configs = [`./Modules/${module}/webpack.mix.js`];
}

if (process.env.theme !== undefined) {
    let theme =
        process.env.theme.charAt(0).toUpperCase() + process.env.theme.slice(1);

    configs = [`./Themes/${theme}/webpack.mix.js`];
}

mix.setPublicPath("./")
    .options({ processCssUrls: false })
    .sourceMaps(true, "eval-source-map")
    .mergeManifest();

let commands = [];

configs.forEach((config) => {
    require(config);

    let module = config.match(/Modules\/(\w+?)\//);
    let theme = config.match(/Themes\/(\w+?)\//);

    if (module !== null) {
        commands.push(`php artisan module:publish ${module[1]}`);
    }

    if (theme !== null) {
        commands.push(`php artisan stylist:publish ${theme[1]}`);
    }
});

mix.after(() => {
    commands.map((command) => {
        execSync(command);
    });
});