Rollup Plugin for JavaScript Obfuscator

1.1.0 · active · verified Sun Apr 19

rollup-plugin-obfuscator is a powerful Rollup plugin designed to integrate `javascript-obfuscator` into the build process. Unlike some alternatives, this plugin requires `javascript-obfuscator` to be installed as a separate peer dependency, ensuring users can always utilize the latest version of the obfuscator. The current stable version is 1.1.0, with updates typically aligning with new releases or needs of `javascript-obfuscator`. A key differentiator is its ability to perform obfuscation either on the entire bundle or, more efficiently, on individual files while excluding open-source dependencies, leading to significant performance improvements during the build process. It provides granular control over which files are obfuscated via include/exclude patterns and supports all configuration options available in `javascript-obfuscator` itself.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to apply obfuscation to a Rollup bundle using the `rollup-plugin-obfuscator`. It shows the basic plugin setup and includes common `javascript-obfuscator` options for a strong obfuscation.

import obfuscator from 'rollup-plugin-obfuscator';

export default {
	input: 'src/main.js',
	output: {
		dir: 'dist',
		format: 'esm'
	},
	plugins: [
		obfuscator({
			// Obfuscate the entire bundle (default is file-by-file)
			// global: true,
			options: {
				// Your javascript-obfuscator options here
				// See what's allowed: https://github.com/javascript-obfuscator/javascript-obfuscator
				compact: true,
				controlFlowFlattening: true,
				deadCodeInjection: true,
				identifierNamesGenerator: 'hexadecimal',
				selfDefending: true,
				sideEffects: true,
				splitStrings: true,
				stringArray: true,
				stringArrayThreshold: 0.75
			}
		}),
	]
}

view raw JSON →