-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
98 lines (94 loc) · 3.16 KB
/
Copy pathvite.config.ts
File metadata and controls
98 lines (94 loc) · 3.16 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
/// <reference types="vitest/config" />
import { execSync } from "node:child_process";
import tailwindcss from "@tailwindcss/vite";
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
const buildDate = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
let buildSha = "dev";
try {
buildSha = execSync("git rev-parse --short HEAD").toString().trim();
} catch {
// not a git checkout (e.g. tarball build)
}
const port = process.env.PORT ? Number(process.env.PORT) : undefined;
export default defineConfig({
server: {
port,
strictPort: port !== undefined,
},
preview: { port, strictPort: port !== undefined },
build: {
// echarts is a large charting library that legitimately lands ~550 kB in its
// own dedicated chunk; raise the warning limit so that expected chunk doesn't
// trip the default 500 kB advisory.
chunkSizeWarningLimit: 600,
rolldownOptions: {
output: {
codeSplitting: {
// Group heavy vendor deps into stable chunks. Deliberately no `src`
// catch-all group: a `{ test: /src/ }` group would fold every app
// module — including the lazy route views — into one chunk, defeating
// the router's dynamic import()s. Leaving src ungrouped lets Rolldown's
// default splitting honour those dynamic-import boundaries, so the
// off-landing views each get their own lazy chunk.
groups: [
{ name: "vue", test: /@vue|vue-router|@vueuse/, priority: 60 },
{ name: "echarts", test: /echarts|vue-echarts|zrender/, priority: 40 },
{ name: "analytics", test: /posthog/, priority: 20 },
{ name: "vendor", test: /node_modules/, priority: 10 },
],
},
},
},
},
define: {
__BUILD_DATE__: JSON.stringify(buildDate),
__BUILD_SHA__: JSON.stringify(buildSha),
},
plugins: [
vue(),
tailwindcss(),
VitePWA({
strategies: "injectManifest",
srcDir: "src",
filename: "sw.ts",
registerType: "prompt",
pwaAssets: {
htmlPreset: "2023",
preset: {
transparent: { sizes: [64, 192, 512], favicons: [[48, "favicon.ico"]] },
maskable: { sizes: [512], padding: 0.15, resizeOptions: { background: "#050810" } },
apple: { sizes: [180], padding: 0.15, resizeOptions: { background: "#050810" } },
},
image: "public/logo.svg",
},
manifest: {
name: "MeteoCompare",
short_name: "MeteoCompare",
description: "Multi-model weather forecast comparison with a weighted aggregate and a predictability signal.",
theme_color: "#050810",
background_color: "#050810",
display: "standalone",
start_url: "/",
scope: "/",
id: "meteocompare",
orientation: "natural",
},
injectManifest: {
globPatterns: ["**/*.{js,css,html,svg,png,ico,woff,woff2}"],
},
devOptions: {
// enabled: true,
type: "module",
},
}),
],
resolve: {
tsconfigPaths: true,
},
test: {
environment: "jsdom",
include: ["src/**/*.test.ts"],
},
});