aboutsummaryrefslogtreecommitdiffstats
path: root/vite.config.js
blob: e54ff9b1147e4a963d24d609cf3943bf193ef834 (plain) (blame)
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
import { sveltekit } from "@sveltejs/kit/vite";
import tailwindcss from "@tailwindcss/vite";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig } from "vite";

export default defineConfig(() => {
	const analyze = process.env.ANALYZE === "true";

	return {
		plugins: [
			tailwindcss({ optimize: false }),
			sveltekit(),
			analyze &&
				visualizer({
					filename: "build/stats.html",
					gzipSize: true,
					brotliSize: true,
					template: "treemap",
				}),
		].filter(Boolean),
	css: {
		transformer: "postcss",
	},
	preview: {
		allowedHosts: [
			"coinos.io",
			"6un2jrlcumn5vduhbq6i3i2wrwiydamwjwop472obg6cy2bfo6ua3oad.onion",
			"vm7h454g5hiy2nt3u5o7evtz3vigtypo2mkyausakvdkbmd7wpyhx5qd.onion",
		],
	},
	server: {
		proxy:
			process.env.NODE_ENV === "development"
				? {
						"/api/": {
							target: "http://localhost:3119",
							rewrite: (path) => path.replace(/^\/api\//, ""),
						},
				  }
				: undefined,
	},
		build: {
			cssMinify: "esbuild",
			chunkSizeWarningLimit: 1000,
			rollupOptions: {
				output: {
					manualChunks(id) {
						if (id.includes("node_modules")) {
							const parts = id.split("node_modules/")[1].split("/");
							const pkg = parts[0].startsWith("@")
								? `${parts[0]}/${parts[1]}`
								: parts[0];
							return `vendor-${pkg}`;
						}
					},
				},
			},
		},
	};
});