Twan07 commited on
Commit
431ee5b
·
verified ·
1 Parent(s): c77fbe4

Update vite.config.ts

Browse files
Files changed (1) hide show
  1. vite.config.ts +38 -11
vite.config.ts CHANGED
@@ -1,23 +1,50 @@
1
  import { defineConfig } from 'vite';
2
  import react from '@vitejs/plugin-react';
 
3
 
4
  export default defineConfig({
5
  server: {
6
- // Cho phép host cụ thể (thêm domain của bạn)
7
- allowedHosts: [
8
- 'twanapi-testupload.hf.space',
9
- // Thêm các host khác nếu cần, ví dụ: '*.hf.space' để cho phép tất cả subdomain HF
10
- ],
11
- // Nếu đang dev trong Docker, thêm host để accessible từ ngoài
12
  host: '0.0.0.0',
13
  port: 5173,
14
  },
15
- plugins: [react()],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  esbuild: {
17
- drop: ['console', 'debugger'], // Xóa log
18
  },
19
  build: {
20
- sourcemap: false, // Ẩn code gốc
21
- minify: 'esbuild', // Nén code nhỏ nhất có thể
 
 
 
 
 
22
  },
23
- });
 
1
  import { defineConfig } from 'vite';
2
  import react from '@vitejs/plugin-react';
3
+ import obfuscator from 'rollup-plugin-obfuscator'; // Import plugin
4
 
5
  export default defineConfig({
6
  server: {
7
+ allowedHosts: ['twanapi-testupload.hf.space'],
 
 
 
 
 
8
  host: '0.0.0.0',
9
  port: 5173,
10
  },
11
+ plugins: [
12
+ react(),
13
+ // Chỉ chạy obfuscator khi build production
14
+ obfuscator({
15
+ global: true, // Áp dụng cho tất cả file
16
+ options: {
17
+ // Cấu hình làm rối code cực mạnh
18
+ compact: true,
19
+ controlFlowFlattening: true, // Làm rối luồng logic if/else
20
+ controlFlowFlatteningThreshold: 1,
21
+ deadCodeInjection: true, // Chèn code giả vào để đánh lừa
22
+ deadCodeInjectionThreshold: 0.4,
23
+ debugProtection: true, // Chống bật F12 console debug
24
+ debugProtectionInterval: 4000, // Treo trình duyệt nếu cố debug
25
+ disableConsoleOutput: true, // Chặn mọi console.log
26
+ identifierNamesGenerator: 'hexadecimal', // Đổi tên biến thành mã hex (0x...)
27
+ log: false,
28
+ renameGlobals: false,
29
+ rotateStringArray: true,
30
+ selfDefending: true, // Code tự bảo vệ khi bị format lại
31
+ stringArray: true,
32
+ stringArrayEncoding: ['rc4'], // Mã hóa chuỗi text
33
+ stringArrayThreshold: 1,
34
+ unicodeEscapeSequence: false
35
+ },
36
+ }),
37
+ ],
38
  esbuild: {
39
+ drop: ['console', 'debugger'],
40
  },
41
  build: {
42
+ sourcemap: false,
43
+ minify: 'esbuild',
44
+ rollupOptions: {
45
+ output: {
46
+ manualChunks: undefined,
47
+ }
48
+ }
49
  },
50
+ });