forked from mental-os/Aurora-OS.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
71 lines (67 loc) · 2.07 KB
/
vite.config.ts
File metadata and controls
71 lines (67 loc) · 2.07 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { compression } from 'vite-plugin-compression2';
import path from 'path';
import { constants as zlibConstants } from 'zlib';
import packageJson from './package.json';
export default defineConfig({
base: './',
clearScreen: false,
plugins: [
react(),
{
name: 'html-transform',
transformIndexHtml(html) {
return html.replace(
/%APP_VERSION%/g,
packageJson.version
);
},
},
// Dual Compression: Brotli (modern browsers) + Gzip (fallback)
// NOTE: Only enabled for WEB builds. Electron uses ASAR compression (maximum).
...(process.env.WEB_BUILD === 'true' ? [
compression({
threshold: 1024, // Only compress files > 1KB
deleteOriginalAssets: false, // Keep uncompressed files
algorithms: [
// Brotli - Best compression for modern browsers (97% support)
['brotliCompress', {
params: {
[zlibConstants.BROTLI_PARAM_QUALITY]: 11, // Max quality for static assets
[zlibConstants.BROTLI_PARAM_MODE]: zlibConstants.BROTLI_MODE_TEXT,
},
}],
// Gzip - Universal fallback
['gzip', { level: 9 }], // Max gzip compression
],
})
] : []),
],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
target: 'esnext',
outDir: 'dist',
minify: 'esbuild',
assetsInlineLimit: 10240,
emptyOutDir: true,
chunkSizeWarningLimit: 1500,
// NOTE: Manual chunks removed for Electron optimization
// Electron loads from local ASAR - no HTTP caching benefit
// Manual chunks add file I/O overhead with no gain
// Lazy loading (per-app chunks) is kept for memory/startup benefits
},
esbuild: {
legalComments: 'none', // Remove all comments for smaller output
treeShaking: true, // Aggressive dead code elimination
},
server: {
port: 3000,
open: true,
},
});