feat(web): 增加代码混淆

This commit is contained in:
v-zhangjc9
2025-06-04 19:19:37 +08:00
parent 577834568b
commit 8b4827b164
3 changed files with 526 additions and 2 deletions

View File

@@ -35,6 +35,7 @@
"sass": "^1.89.0",
"typescript": "~5.8.3",
"typescript-eslint": "^8.33.0",
"vite": "^6.3.5"
"vite": "^6.3.5",
"vite-plugin-javascript-obfuscator": "^3.1.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,34 @@
import react from '@vitejs/plugin-react-swc'
import {defineConfig, type UserConfig} from 'vite'
import obfuscatorPlugin from 'vite-plugin-javascript-obfuscator'
// https://vite.dev/config/
export default defineConfig(({mode}) => {
let config: UserConfig = {
plugins: [react()],
plugins: [
react(),
obfuscatorPlugin({
apply: config => config['mode'] === 'production',
options: {
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
renameGlobals: false,
stringArrayRotate: true,
selfDefending: true,
stringArray: true,
stringArrayEncoding: ['base64'],
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false,
},
}),
],
}
if (mode === 'production') {
config.base = '/hudi_services/service_web'