forked from tonkeeper/ton-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
61 lines (58 loc) · 1.97 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
/// <reference types="vitest" />
/// <reference types="vite/client" />
import { defineConfig, loadEnv } from 'vite';
import mkcert from 'vite-plugin-mkcert';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { createHtmlPlugin } from 'vite-plugin-html';
export default ({ mode }) => {
const { VITE_TG_OAUTH_BOT_NAME, VITE_BASE_PROXY_URL } = loadEnv(mode, process.cwd());
return defineConfig({
plugins: [
tsconfigPaths(),
react(),
mkcert(),
createHtmlPlugin({
entry: '/src/main.tsx',
inject: {
data: {
injectScript: `<script async src="https://telegram.org/js/telegram-widget.js?22" data-telegram-login="${VITE_TG_OAUTH_BOT_NAME}" data-userpic="false" data-request-access="write" onload="setTimeout(document.getElementById('telegram-login-${VITE_TG_OAUTH_BOT_NAME}').style.display = 'none')"></script>`
},
tags: [
{
injectTo: 'body-prepend',
tag: 'div',
attrs: {
id: 'root'
}
}
]
}
})
],
server: {
host: '127.0.0.1',
port: 5173,
https: true,
watch: {
usePolling: true
},
proxy: {
'/api': {
target: VITE_BASE_PROXY_URL,
changeOrigin: true,
secure: true,
cookiePathRewrite: '/'
}
}
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: './tests/setup.ts',
typecheck: {
tsconfig: './tsconfig.test.json'
}
}
});
};