-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
55 lines (54 loc) · 1.16 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
49
50
51
52
53
54
55
import { defineConfig } from "vite";
import fs from "fs";
import path from "path";
import react from "@vitejs/plugin-react";
const getGit = () => {
const rev = fs.readFileSync(".git/HEAD").toString().trim();
if (rev.indexOf(":") === -1) {
return rev;
}
return fs
.readFileSync(`.git/${rev.substring(5)}`)
.toString()
.trim();
};
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
console.log("⧭ cross-env MODE:", process.env.MODE);
console.log("⧭ mode:", mode);
return {
plugins: [react()],
build: {
minify: process.env.MODE === "prd" ? "terser" : "esbuild",
...(process.env.MODE === "prd"
? {
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
}
: {}),
},
define: {
__GIT_HASH__: JSON.stringify(getGit()),
__MODE__: JSON.stringify(process.env.MODE),
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
proxy: {
"^/cat-api": {
secure: true,
changeOrigin: true,
target: "https://api.thecatapi.com",
rewrite: (path) => path.replace(/^\/cat-api/, ""),
},
},
},
};
});