-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.ts
48 lines (45 loc) · 1.38 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 { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import basicSsl from '@vitejs/plugin-basic-ssl'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import * as child from "child_process"
const commitHash = child.execSync("git rev-parse --short HEAD").toString() //i.e., 706e821
const tagAndCommitHash = child.execSync("git describe --always --tags").toString() //i.e., v23.5.0-1-g706e821
const buildDate = new Date().toUTCString()
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
basicSsl(),
nodePolyfills({ // hashgraph/proto needs NodeJS buffers
exclude: [
'fs', // Excludes the polyfill for `fs` and `node:fs`.
],
globals: {
Buffer: true,
global: false,
process: true,
},
protocolImports: false,
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
commonjsOptions: {
transformMixedEsModules: true, // else hashconnect crashes because require() is undefined :(
},
},
define: {
'import.meta.env.VITE_BUILD_SHORTCOMMITHASH': JSON.stringify(commitHash),
'import.meta.env.VITE_BUILD_RELEASE': JSON.stringify(tagAndCommitHash),
'import.meta.env.VITE_BUILD_TIME_UTC': JSON.stringify(buildDate),
},
worker: {
format: "es",
}
})