-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
62 lines (55 loc) · 1.91 KB
/
vite.config.js
File metadata and controls
62 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path' // Tambahkan impor path
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
// ========================================================
// FIX KRUSIAL 3: Menambahkan Path Alias (@) untuk Absolute Import
// Memungkinkan import seperti: import MyComp from '@/components/MyComp'
// ========================================================
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
}
},
// Konfigurasi Server
server: {
host: '0.0.0.0',
allowedHosts: [
'localhost',
'127.0.0.1',
'*.ngrok-free.app',
'dev-tunnel.local'
]
},
// ========================================================
// FIX KRUSIAL 1: Memaksa Vite memproses dependensi (optimizeDeps)
// Sekarang termasuk semua packages untuk dokumen (docx, xlsx, pdf) dan file-saver.
// ========================================================
optimizeDeps: {
include: [
'@tensorflow/tfjs',
'@tensorflow-models/face-landmarks-detection',
// Memastikan MediaPipe di-pre-bundle
'@mediapipe/face_mesh',
// FIX untuk error "Failed to resolve import"
'xlsx',
'docx',
'file-saver',
'jspdf',
'jspdf-autotable'
],
},
// ========================================================
// FIX KRUSIAL 2: Mengatasi BUG WASM MediaPipe (RuntimeError: abort)
// Ini adalah penyesuaian utama untuk error WASM.
// ========================================================
build: {
// 1. Memastikan file kecil tidak di-inline sebagai Base64,
// yang dapat mengganggu worker WASM (set ke 0 untuk wasm/worker)
assetsInlineLimit: 0,
},
// 2. Memberitahu Vite untuk memperlakukan semua file WASM, tflite, dan bin sebagai assets
assetsInclude: ['**/*.tflite', '**/*.bin', '**/*.wasm'],
})