-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
73 lines (62 loc) · 2.37 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { VitePWA } from "vite-plugin-pwa";
import basicSSL from "@vitejs/plugin-basic-ssl";
import childProcess from "child_process";
// Get git values to be use in the vue app
const gitValues = {
commitHash: childProcess.execSync("git rev-parse HEAD").toString(),
gitBranch: childProcess
.execSync("git rev-parse --abbrev-ref HEAD")
.toString(),
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
// Plugin to enable PWA usage
VitePWA({
// Allow PWA to be tested in development mode
devOptions: { enabled: true },
registerType: "autoUpdate",
// Values in the generated manifest file
manifest: {
name: "HazMatrix",
},
}),
// Enable https by default as ios requires https connections to give camera access
// https://vitejs.dev/config/server-options.html#server-https
// https://vitejs.dev/guide/migration.html#automatic-https-certificate-generation
basicSSL(),
],
/**
* Replace these strings with the appropriate values during build time.
* Update `.eslintrc.cjs` and `env.d.ts` whenever new values are added to get typing and lint support
*
*
* ****IMPORTANT NOTE****
* All the string values MUST be wrapped in a `JSON.stringify()` call as string values will be used
* as raw expressions starting from vite v2. JSON.stringify will convert it to be explicitly quoted.
*
* Reference:
* - https://vitejs.dev/config/shared-options.html#define
* - https://github.com/vitejs/vite/issues/6235
* - https://github.com/vitejs/vite/issues/2058
* - https://github.com/vitejs/vite/commit/30deabf4aaf7acafdf854f8950355b48be46d9db
*/
define: {
"__vite_inject.commitHash": JSON.stringify(gitValues.commitHash),
"__vite_inject.gitBranch": JSON.stringify(gitValues.gitBranch),
// CI/CD build server might not be in SG, so store date as ISO string, to create a new Date object when viewing to show time in user's locale
"__vite_inject.buildTime": JSON.stringify(new Date()),
// Pass in the content in the CNAME file so that the baseURL can be created properly
"__vite_inject.CNAME": JSON.stringify(
require("fs")
.readFileSync(
require("path").resolve(__dirname, "./public/CNAME"),
"utf8"
)
.trim()
),
},
});