-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
65 lines (61 loc) · 1.8 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
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'url'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import inject from '@rollup/plugin-inject'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv } from 'vite'
import vitePluginRequire from 'vite-plugin-require'
import topLevelAwait from 'vite-plugin-top-level-await'
import wasm from 'vite-plugin-wasm'
import { configDefaults } from 'vitest/config'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const envVariables = {
VITE_HOLOPORT_URL: env.VITE_HOLOPORT_URL,
VITE_HPOS_PORT: env.VITE_HPOS_PORT,
VITE_UI_VERSION: env.VITE_UI_VERSION
}
if (env.NODE_ENV === 'development') {
console.log(envVariables)
}
return {
resolve: {
alias: {
'@': resolve(dirname(fileURLToPath(import.meta.url)), './src'),
'@uicommon': resolve(dirname(fileURLToPath(import.meta.url)), './ui-common-library/src')
},
extensions: ['.js', '.ts', '.vue', '.json']
},
plugins: [
wasm(),
topLevelAwait(),
vue(),
VueI18nPlugin({
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/locales/**'),
runtimeOnly: false,
bridge: true
}),
vitePluginRequire(),
inject({
Buffer: ['buffer', 'Buffer']
})
],
server:
env.NODE_ENV === 'production' || env.NODE_ENV === 'test'
? {}
: env.VITE_HOLOPORT_URL && {
port: 8080,
proxy: {
'^/api/*': {
target: env.VITE_HOLOPORT_URL,
changeOrigin: true
}
}
},
test: {
environment: 'happy-dom',
globals: true,
exclude: [...configDefaults.exclude, '**/ui-common-library/**']
}
}
})