webpack-javascript-obfuscator-plugin
v1.0.9
Published
一个简易的webpack加密javascript的插件
Downloads
28
Maintainers
Readme
webpack-javascript-obfuscator-plugin
本插件依赖javascript-obfuscator对前端代码进行AST混淆加密
Install
With npm:
npm i webpack-javascript-obfuscator-plugin --save-dev
Or yarn:
yarn add webpack-javascript-obfuscator-plugin --dev
Usage
首先引入
// 引入
const WebpackJavascriptObfuscatorPlugin = require("webpack-javascript-obfuscator-plugin");
在webpack的插件选项中
//在webpack的plugins中实例化此插件
plugins: [ new WebpackJavascriptObfuscatorPlugin(options) ]
//如果你只想在打包时进行加密
plugins: process.env.NODE_ENV == "production" ? [ new WebpackJavascriptObfuscatorPlugin(options) ] : []
Options(不添加默认中度混淆,最佳性能)
默认:
{
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: true,
identifierNamesGenerator: "hexadecimal",
log: false,
numbersToExpressions: true,
renameGlobals: false,
rotateStringArray: true,
selfDefending: false,
shuffleStringArray: true,
simplify: true,
splitStrings: true,
splitStringsChunkLength: 10,
stringArray: true,
stringArrayEncoding: ["base64"],
stringArrayIndexShift: true,
stringArrayWrappersCount: 2,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 4,
stringArrayWrappersType: "function",
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false
}
添加或修改配置项请移步JavaScript Obfuscator Options