没有废话,直接上(链接)代码。爬坑无数,干货满满
开始操作😏
yarn add vite-plugin-bundle-obfuscator // 安装混淆插件
vue3项目默认在vite.config.ts文件中进行配置/自定义的vite文件
guthub源代码地址:github.com/z0ffy/vite-…
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator'; // 引入组件
// 在插件位置(plugins)中添加组件的信息
plugins: [vitePluginBundleObfuscator({
excludes: [],
enable: true,
log: true,
autoExcludeNodeModules: false,
threadPool: 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, // 注意此处一定要设置为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,
},
})],
stringArray:为true的话,会报错 TypeError: _0x3fe4b6[_0x53c610(...)] is not a function...
-
- 打包成功后在dist文件中查看相关js的代码/在浏览器F12源代码/source中查看原文见
无效插件(迅速避坑)
vite-mahlzeit-obfuscator
vite-plugin-javascript-obfuscator
rollup-plugin-javascript-obfuscator
vite-plugin-obfuscator