-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
48 lines (44 loc) · 1.24 KB
/
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
46
47
48
import { ConfigEnv, defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import Icons from "unplugin-icons/vite";
import mkcert from "vite-plugin-mkcert";
import os from "os";
import path from "path";
import { execSync } from "child_process";
function zvelteCssHash({ name, filename, css, hash }): string {
// eg. z-ServerList, z-Tooltip, z-Button
return `z-${name}`;
}
// https://vitejs.dev/config/
export default defineConfig((env: ConfigEnv) => {
let version;
try {
version = execSync("git rev-parse HEAD")
.toString()
.trimEnd()
.substr(0, 7);
} catch (e) {
console.error("Failed to get commit hash");
version = "unknown";
}
return {
plugins: [
svelte({ compilerOptions: { cssHash: zvelteCssHash } }),
Icons({
compiler: "svelte",
}),
mkcert({savePath: path.join(os.homedir(),".local","share","zling-certs")}),
],
define: {
ZLING_VERSION: JSON.stringify(version),
},
server: {
port: 2000,
https: true,
open: true,
},
preview: {
port: 2000,
}
};
});