-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
39 lines (36 loc) · 1.09 KB
/
vite.config.ts
File metadata and controls
39 lines (36 loc) · 1.09 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
import { execSync } from "node:child_process";
import { fileURLToPath, URL } from "node:url";
import Vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import VueRouter from "vue-router/vite";
import type { TreeNode } from "vue-router/unplugin";
import PWA_OPTIONS from "./src/constants/pwa-options.ts";
const commitDate = execSync("git log -1 --format=%cI").toString().trimEnd();
function getRouteName(node: TreeNode): string {
if (!node.parent) return "";
const parentName = getRouteName(node.parent);
let name = node.value.rawSegment;
name = name[0].toUpperCase() + name.slice(1);
if (!parentName) return name;
return parentName;
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
VueRouter({ dts: "./src/types/typed-router.ts", getRouteName }),
Vue(),
VitePWA(PWA_OPTIONS)
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
define: {
"import.meta.env.VITE_GIT_COMMIT_DATE": JSON.stringify(commitDate)
},
server: {
port: 7400
}
});