-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
41 lines (39 loc) · 1.38 KB
/
Copy pathvite.config.ts
File metadata and controls
41 lines (39 loc) · 1.38 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
40
41
import { defineConfig } from "vite";
import { execSync } from "child_process";
import { ViteMinifyPlugin } from "vite-plugin-minify";
import preload from "vite-plugin-preload";
import viteCompression from "vite-plugin-compression";
const buildTime = Date.now();
const buildDate = new Date(buildTime).toISOString();
const gitCommit = execSync("git rev-parse --short HEAD").toString().trim();
const gitCommitFull = execSync("git rev-parse HEAD").toString().trim();
const gitCurrentBranch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
export default defineConfig({
plugins: [
ViteMinifyPlugin({
ignoreCustomComments: [],
}),
viteCompression(),
preload(),
],
define: {
"import.meta.env.VITE_BUILD_TIME": JSON.stringify(buildTime),
"import.meta.env.VITE_BUILD_DATE": JSON.stringify(buildDate),
"import.meta.env.VITE_GIT_COMMIT": JSON.stringify(gitCommit),
"import.meta.env.VITE_GIT_COMMIT_FULL": JSON.stringify(gitCommitFull),
"import.meta.env.VITE_GIT_CURRENT_BRANCH": JSON.stringify(gitCurrentBranch),
},
build: {
minify: "terser",
sourcemap: "hidden",
cssCodeSplit: false,
terserOptions: {
parse: {
html5_comments: false,
},
format: {
comments: false,
},
},
},
});