Webpack Obfuscator Plugin and Loader

3.6.1 · active · verified Sun Apr 19

webpack-obfuscator is a JavaScript Obfuscator plugin and loader designed specifically for Webpack 5 and above. It integrates the robust `javascript-obfuscator` library into the Webpack build process, allowing developers to protect their JavaScript code by making it harder to read and reverse-engineer. The current stable version is 3.6.1. Releases appear to be frequent, focusing on dependency updates and minor enhancements, indicating an active maintenance schedule. A key differentiator is its seamless integration as both a Webpack plugin and a loader, offering flexibility in how obfuscation is applied, including the ability to exclude specific bundles or files. It also supports the obfuscator.io Pro API for advanced, cloud-based obfuscation techniques, requiring `javascript-obfuscator` version 5.0.0 or higher for this feature.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic Webpack configuration applying `webpack-obfuscator` as both a plugin (for global bundle obfuscation with exclusions) and a loader (for individual file obfuscation before other loaders, using `enforce: 'post'`).

const path = require('path');
const WebpackObfuscator = require('webpack-obfuscator');

module.exports = {
    mode: 'production',
    entry: {
        'main': './src/index.js'
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].js'
    },
    plugins: [
        new WebpackObfuscator({
            rotateStringArray: true,
            stringArrayThreshold: 0.75
        }, ['main.js'])
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                enforce: 'post',
                use: {
                    loader: WebpackObfuscator.loader,
                    options: {
                        compact: true
                    }
                }
            }
        ]
    }
};

view raw JSON →