Spaces:
Running
Running
Update vite.config.ts
Browse files- vite.config.ts +19 -62
vite.config.ts
CHANGED
|
@@ -1,66 +1,23 @@
|
|
| 1 |
import { defineConfig } from 'vite';
|
| 2 |
import react from '@vitejs/plugin-react';
|
| 3 |
-
import obfuscator from 'rollup-plugin-obfuscator';
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
server: {
|
| 12 |
-
allowedHosts: ['twanapi-testupload.hf.space'],
|
| 13 |
-
host: '0.0.0.0',
|
| 14 |
-
port: 5173,
|
| 15 |
-
},
|
| 16 |
-
plugins: [
|
| 17 |
-
react(),
|
| 18 |
-
// Logic quan trọng: Chỉ chạy obfuscator khi đang Build Production
|
| 19 |
-
// Nếu chạy Dev, plugin này sẽ bị bỏ qua để máy chạy nhanh
|
| 20 |
-
isBuild && obfuscator({
|
| 21 |
-
global: true,
|
| 22 |
-
options: {
|
| 23 |
-
// --- CẤU HÌNH BẢO MẬT MẠNH ---
|
| 24 |
-
compact: true,
|
| 25 |
-
controlFlowFlattening: true,
|
| 26 |
-
controlFlowFlatteningThreshold: 1,
|
| 27 |
-
deadCodeInjection: true,
|
| 28 |
-
deadCodeInjectionThreshold: 0.4,
|
| 29 |
-
|
| 30 |
-
// Chống debug & Console
|
| 31 |
-
debugProtection: true,
|
| 32 |
-
debugProtectionInterval: 4000,
|
| 33 |
-
disableConsoleOutput: true,
|
| 34 |
-
|
| 35 |
-
// Mã hóa tên biến & chuỗi
|
| 36 |
-
identifierNamesGenerator: 'hexadecimal',
|
| 37 |
-
log: false,
|
| 38 |
-
renameGlobals: false,
|
| 39 |
-
rotateStringArray: true,
|
| 40 |
-
selfDefending: true,
|
| 41 |
-
stringArray: true,
|
| 42 |
-
stringArrayEncoding: ['rc4'],
|
| 43 |
-
stringArrayThreshold: 1,
|
| 44 |
-
unicodeEscapeSequence: false,
|
| 45 |
-
|
| 46 |
-
// Loại bỏ domainLock (để tránh lỗi khi đổi domain trên HF)
|
| 47 |
-
domainLock: [],
|
| 48 |
-
},
|
| 49 |
-
}),
|
| 50 |
],
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
},
|
| 65 |
-
};
|
| 66 |
-
});
|
|
|
|
| 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 |
+
});
|
|
|
|
|
|
|
|
|