HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/dmstechonline/whatsapp.dmstech.online/node_modules/laravel-vue-i18n/dist/mix.mjs
import path from 'path';
import fs from 'fs';
import mix from 'laravel-mix';
import { Component } from 'laravel-mix/src/components/Component';
import { EnvironmentPlugin } from 'webpack';
import { generateFiles, parseAll, hasPhpTranslations } from "./loader.mjs";
class BeforeBuildPlugin {
    constructor(callback) {
        this.callback = callback;
    }
    apply(compiler) {
        compiler.hooks.compile.tap('BeforeBuildPlugin', this.callback);
    }
}
mix.extend('i18n', class extends Component {
    register(langPath = 'lang') {
        this.langPath = this.context.paths.rootPath + path.sep + langPath + path.sep;
        this.frameworkLangPath =
            this.context.paths.rootPath +
                path.sep +
                'vendor/laravel/framework/src/Illuminate/Translation/lang/'.replace('/', path.sep);
    }
    webpackConfig(config) {
        let files = [];
        config.watchOptions = {
            ignored: /php.*\.json/
        };
        if (hasPhpTranslations(this.langPath)) {
            config.plugins.push(new EnvironmentPlugin({
                LARAVEL_VUE_I18N_HAS_PHP: true
            }));
        }
        config.plugins.push(new BeforeBuildPlugin(() => {
            files = generateFiles(this.langPath, [...parseAll(this.frameworkLangPath), ...parseAll(this.langPath)]);
        }));
        this.context.listen('build', () => {
            files.forEach((file) => {
                if (fs.existsSync(this.langPath + file.name)) {
                    fs.unlinkSync(this.langPath + file.name);
                }
            });
            if (fs.existsSync(this.langPath) && fs.readdirSync(this.langPath).length < 1) {
                fs.rmdirSync(this.langPath);
            }
        });
    }
});
//# sourceMappingURL=mix.mjs.map