forked from spacesprotocol/explorer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
102 lines (86 loc) · 2.1 KB
/
Copy pathvite.config.ts
File metadata and controls
102 lines (86 loc) · 2.1 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, type ProxyOptions } from 'vite';
import fs from 'fs';
import dotenv from 'dotenv';
dotenv.config();
const { SSL_CERT_PATH, SSL_KEY_PATH } = process.env;
const server: { proxy: Record<string, string | ProxyOptions>, https?: object} = {
proxy: {},
}
if (SSL_CERT_PATH && SSL_KEY_PATH) {
server.https = {
key: fs.readFileSync(SSL_KEY_PATH),
cert: fs.readFileSync(SSL_CERT_PATH)
}
}
export default defineConfig({
plugins: [sveltekit()],
build: {
// Disable source maps in production
sourcemap: false,
// Production minification
minify: 'esbuild',
target: 'esnext',
// Optimize output chunks
rollupOptions: {
output: {
// Optimize chunk size
chunkFileNames: 'chunks/[name].[hash].js',
entryFileNames: 'entries/[name].[hash].js',
assetFileNames: 'assets/[name].[hash][extname]',
// Manual chunk splitting
manualChunks: (id) => {
// Group dayjs and its plugins
if (id.includes('dayjs')) {
return 'vendor-dayjs';
}
// Group common components
if (id.includes('/lib/components/layout/')) {
return 'common-layout';
}
// Group feature components
if (id.includes('/lib/components/')) {
if (id.includes('RecentActions') || id.includes('Rollout') || id.includes('Stats')) {
return 'features';
}
}
// Group other node_modules
if (id.includes('node_modules')) {
const module = id.split('node_modules/').pop()?.split('/')[0];
if (module) {
return `vendor-${module}`;
}
}
}
}
},
// Reduce chunk sizes
chunkSizeWarningLimit: 1000,
},
// Optimize CSS
css: {
preprocessorOptions: {
css: {
imports: true
}
},
devSourcemap: false
},
// Your server config
server,
optimizeDeps: {
// Include frequently used dependencies
include: [
'dayjs',
'dayjs/plugin/utc',
'dayjs/plugin/relativeTime',
'dayjs/plugin/localizedFormat'
]
},
// Enable modern browser optimizations
esbuild: {
target: 'esnext',
platform: 'browser',
treeShaking: true
}
});