Repository navigation
Expand file tree
/
Copy pathvite.config.js
More file actions
executable file
·76 lines (74 loc) · 1.86 KB
/
Copy pathvite.config.js
File metadata and controls
executable file
·76 lines (74 loc) · 1.86 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig } from 'vite';
import legacy from '@vitejs/plugin-legacy';
import { comlink } from 'vite-plugin-comlink';
export default defineConfig(({ mode }) => ({
// Environment variable configuration
envDir: './',
envPrefix: 'VITE_',
plugins: [
comlink(),
legacy({
targets: ['defaults', 'not IE 11'],
modernPolyfills: true
})
],
worker: {
format: 'es',
plugins: () => [comlink()]
},
build: {
rollupOptions: {
input: {
main: 'index.html',
debug: 'debug.html'
},
output: {
assetFileNames: 'assets/[name]-[hash][extname]',
chunkFileNames: 'assets/[name]-[hash].js',
entryFileNames: 'assets/[name]-[hash].js',
// Bundle dependencies for offline operation
manualChunks: {
'transformers': ['@huggingface/transformers'],
'pdf-lib': ['pdfjs-dist']
}
}
},
// Optimize for offline usage
target: 'es2020',
cssCodeSplit: false, // Keep CSS in single file
sourcemap: false, // Reduce build size for production
minify: 'terser',
terserOptions: {
compress: {
drop_console: true, // Remove console logs in production
drop_debugger: true
}
}
},
server: {
port: 3000,
open: true,
fs: {
allow: ['..']
},
// Headers for CORS and model loading
headers: {
'Cross-Origin-Embedder-Policy': 'credentialless',
'Cross-Origin-Opener-Policy': 'same-origin'
}
},
preview: {
port: 3000
},
// Include AI model files and assets
assetsInclude: ['**/*.onnx', '**/*.webp', '**/*.json', '**/*.wasm', '**/*.worker.mjs'],
appType: 'mpa',
// Optimize dependencies for bundling
optimizeDeps: {
include: ['pdfjs-dist', '@huggingface/transformers'],
exclude: ['onnxruntime-web'],
esbuildOptions: {
target: 'es2020'
}
}
}));