Spaces:
Sleeping
Sleeping
| import { defineConfig } from 'vite'; | |
| import react from '@vitejs/plugin-react'; | |
| import obfuscator from 'rollup-plugin-obfuscator'; // Import plugin | |
| export default defineConfig({ | |
| server: { | |
| allowedHosts: ['twanapi-testupload.hf.space'], | |
| host: '0.0.0.0', | |
| port: 5173, | |
| }, | |
| plugins: [ | |
| react(), | |
| // Chỉ chạy obfuscator khi build production | |
| obfuscator({ | |
| global: true, // Áp dụng cho tất cả file | |
| options: { | |
| // Cấu hình làm rối code cực mạnh | |
| compact: true, | |
| controlFlowFlattening: true, // Làm rối luồng logic if/else | |
| controlFlowFlatteningThreshold: 1, | |
| deadCodeInjection: true, // Chèn code giả vào để đánh lừa | |
| deadCodeInjectionThreshold: 0.4, | |
| debugProtection: true, // Chống bật F12 console debug | |
| debugProtectionInterval: 4000, // Treo trình duyệt nếu cố debug | |
| disableConsoleOutput: true, // Chặn mọi console.log | |
| identifierNamesGenerator: 'hexadecimal', // Đổi tên biến thành mã hex (0x...) | |
| log: false, | |
| renameGlobals: false, | |
| rotateStringArray: true, | |
| selfDefending: true, // Code tự bảo vệ khi bị format lại | |
| stringArray: true, | |
| stringArrayEncoding: ['rc4'], // Mã hóa chuỗi text | |
| stringArrayThreshold: 1, | |
| unicodeEscapeSequence: false | |
| }, | |
| }), | |
| ], | |
| esbuild: { | |
| drop: ['console', 'debugger'], | |
| }, | |
| build: { | |
| sourcemap: false, | |
| minify: 'esbuild', | |
| rollupOptions: { | |
| output: { | |
| manualChunks: undefined, | |
| } | |
| } | |
| }, | |
| }); | |