-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathvite.config.ts
More file actions
32 lines (30 loc) · 1.2 KB
/
Copy pathvite.config.ts
File metadata and controls
32 lines (30 loc) · 1.2 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
import { fileURLToPath, URL } from "node:url";
/**
* The desktop app ships the same renderer, minus the parts that only make sense on the web:
* Google Analytics (a program that phones home on launch is a different bargain than a web page),
* and the PWA plumbing, which `services/platform.ts` already skips under Electron
*/
const stripWebOnlyTags = {
name: "strip-web-only-tags",
transformIndexHtml: (html: string) =>
html
.replace(/<script async src="https:\/\/www\.googletagmanager\.com[^>]*><\/script>\s*/, "")
.replace(/<script>\s*window\.dataLayer[\s\S]*?<\/script>\s*/, "")
.replace(/<link rel="manifest"[^>]*>\s*/, "")
};
export default ({ mode }: { mode: string }) => ({
root: "./src",
base: mode === "electron" ? "./" : process.env.NETLIFY ? "/" : "/Fantasy-Map-Generator/",
plugins: mode === "electron" ? [stripWebOnlyTags] : [],
build: {
outDir: mode === "electron" ? "../dist-electron/renderer" : "../dist",
assetsDir: "./",
emptyOutDir: true // outDir sits outside root, so Vite would otherwise keep every past build's chunks
},
publicDir: "../public",
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
}
});