JavaScript obfuscator plugin for Vite environments
Changelog · Report Bug · Request Feature
English | Chinese
- 💎 ?support the node_modules split chunk
- If the obfuscation option stringArray is true.
- Your results may lose some bundles (in __vite__mapDeps array).
- I'm looking for an accurate case.
npm install vite-plugin-bundle-obfuscator -D
- Run npm install vite-plugin-bundle-obfuscator -D
- Register the plugin in
vite.config.js
- Set your own configuration or set empty to use default options
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator';
const obfuscatorConfig = {
enable: true,
log: true,
autoExcludeNodeModules: true,
excludes: [],
options: {}
};
export default {
plugins: [vitePluginBundleObfuscator(obfuscatorConfig)]
};
Property Name | Description | Type | Default | Version |
---|---|---|---|---|
log | Show or hide log output. | boolean | true | v1.0.4 |
enable | Enable or disable the obfuscator. | boolean | true | v1.0.1 |
autoExcludeNodeModules | Enable auto exclude node_modules. | boolean | false | v1.0.9 |
apply | Apply the plugin only for serve or build, or on certain conditions. | 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | build | v1.1.0 |
excludes | Bundle names to be excluded. Starting from v1.0.8, RegExp is supported. | (RegExp | string)[] | [] | v1.0.0 |
options | Options for the JavaScript obfuscator. | ObfuscatorOptions | Config example | v1.0.0 |
const obfuscatorConfig = {
excludes: [],
enable: true,
log: true,
autoExcludeNodeModules: false,
options: {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: true,
simplify: true,
splitStrings: false,
stringArray: false,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false,
}
};