-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.js
More file actions
83 lines (79 loc) · 2.5 KB
/
vite.config.js
File metadata and controls
83 lines (79 loc) · 2.5 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
import tailwindcss from "@tailwindcss/vite";
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [tailwindcss(), sveltekit()],
server: {
host: true, // Allow external access when --host flag is used
port: 5174,
strictPort: true, // Exit if port is already in use instead of trying another
cors: true, // Enable CORS for development
headers: {
"Cache-Control": "no-cache", // Prevent caching issues during development
},
allowedHosts: [
process.env.DOMAIN || "localhost",
process.env.GGREQUESTZ_HOST || "localhost",
"localhost",
"127.0.0.1",
"192.168.10.54",
],
fs: {
// Allow serving files from the entire project
allow: [".."],
},
},
build: {
rollupOptions: {
output: {
// Split vendor libraries into separate chunks for better caching
manualChunks: {
vendor: ["svelte"],
icons: ["@iconify/svelte"],
utils: ["$lib/api.client.js"],
cache: ["$lib/gameCache.js", "$lib/cache.js"],
client: ["$lib/clientServices.js", "$lib/performance.js"],
},
},
},
// Reduce chunk size warning threshold to catch large bundles
chunkSizeWarningLimit: 600,
// Enable source maps for better debugging (remove in production)
sourcemap: process.env.NODE_ENV === "development",
// Enable minification for smaller bundle sizes (only in production)
minify: process.env.NODE_ENV === "production" ? "terser" : false,
...(process.env.NODE_ENV === "production" && {
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
}),
},
// Optimize dependencies
optimizeDeps: {
include: ["@iconify/svelte", "canvas-confetti"],
exclude: ["@iconify-json/*"], // Don't pre-bundle icon sets
// Force dependency pre-bundling for better dev server performance
force: process.env.NODE_ENV === "development",
},
// Performance optimizations
performance: {
hints: "warning",
maxEntrypointSize: 500000,
maxAssetSize: 300000,
},
// Define server-only modules to prevent client-side bundling
define: {
global: "globalThis",
// Vue feature flags for @scalar/api-reference
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
},
// External server-only dependencies for client build
ssr: {
noExternal: [],
},
});