-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathvite.config.ts
70 lines (67 loc) · 1.52 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
import { resolve, join } from 'path'
import react from '@vitejs/plugin-react-swc'
import { defineConfig, type UserConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import svgr from 'vite-plugin-svgr'
import tsConfigPaths from 'vite-tsconfig-paths'
import { createHtmlPlugin } from 'vite-plugin-html'
import 'vitest/config'
const {
NODE_ENV = 'dev',
VITE_WASM_BASE_URL = '/wasm/',
VITE_WASM_API_VER = 'v2',
VITE_BASE_URL = '',
} = process.env
const PROXY_HOST = process.env.LISTEN_ADDR || '127.0.0.1:8000';
export default defineConfig({
resolve: {
alias: {
'~': resolve(__dirname, './src'),
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: join(__dirname, 'src/setupTests.ts'),
alias: [
{
find: /^monaco-editor$/,
replacement:
join(__dirname,'node_modules/monaco-editor/esm/vs/editor/editor.api'),
},
],
},
server: {
port: 3000,
host: '0.0.0.0',
proxy: {
'/api': `http://${PROXY_HOST}`,
}
},
build: {
outDir: 'build',
},
plugins: [
react(),
tsConfigPaths(),
createHtmlPlugin({
minify: true,
template: './src/pages/index.html',
inject: {
data: {
PROD: NODE_ENV === 'production',
VITE_WASM_BASE_URL,
VITE_WASM_API_VER,
VITE_BASE_URL,
},
},
}),
svgr({ svgrOptions: { icon: true } }),
nodePolyfills({
globals: {
Buffer: true,
process: true,
},
}),
],
})