V
V
viktorleg2021-08-22 01:12:10
PHP
viktorleg, 2021-08-22 01:12:10

Why doesn't the plugin change class names in WordPress php files?

I'm trying to obfuscate (encrypt/reduce) class names in a WordPress template.
Through webpack, I connected the plugin for obfuscation mangle-css-class-webpack-plugin and when the command is run, the whole process passes without error and the classes from the css file are reduced, but there are no classes from the php files.

configuration file

webpack.config.js

const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MangleCssClassPlugin = require('mangle-css-class-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
  mode: 'development',
  entry: [
        './src/index.js',
        './index.php'
    ],
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: '[name].js'
    },
    module: {
    rules: [
            { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
            { test: /\.css$/i, use: [ MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { importLoaders: 1, modules: false } }, { loader: 'postcss-loader' } ] },
            {
                test: /\.php$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name: '[path][name].[ext]',
                            outputPath: '/'
                        }
                    }
                ]
            },
        ]
  },
    plugins: [
        new CleanWebpackPlugin(),
        new MiniCssExtractPlugin({
            filename: "assets/css/main.css"
        }),
        new MangleCssClassPlugin({
            classNameRegExp: '((hover|focus|active|disabled|visited|first|last|odd|even|group-hover|focus-within|xs|sm|md|lg|xl)[\\\\]*:)*tw-[a-zA-Z0-9_-]*([\\\\]*\/[0-9]*)?',
            ignorePrefixRegExp: '((hover|focus|active|disabled|visited|first|last|odd|even|group-hover|focus-within|xs|sm|md||lg|xl)[\\\\]*:)*',
            reserveClassName: ['fa', 'fas', 'far'],
            log: true
        })
    ],
};



The feeling that Webpack does not scan classes from php files in any way, or I'm most likely doing something wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question