-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
vite.config.ts
45 lines (39 loc) · 1008 Bytes
/
vite.config.ts
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
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { productName, version } from "./package.json";
const platform = process.env.YUKINO_PLATFORM || "unknown";
export default defineConfig({
base: getBase(platform),
plugins: [
vue(),
{
name: "transform-html",
enforce: "pre",
transformIndexHtml(html) {
html = html.replace("{{ head }}", getHead(platform));
return html;
},
},
],
build: {
outDir: "dist/vite",
},
define: {
app_name: `"${productName}"`,
app_platform: `"${platform}"`,
app_version: `"${version}"`,
app_builtAt: Date.now(),
},
});
function getBase(platform: string) {
switch (platform) {
case "electron":
return "./";
default:
return "/";
}
}
function getHead(platform: string) {
const head: string[] = [];
return head.join("\n");
}