desktop 앱 적용
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const frontendRoot = path.resolve(__dirname, '../frontend/src');
|
||||
const sharedRoot = path.resolve(__dirname, '../packages/shared/src');
|
||||
|
||||
const host = process.env.TAURI_DEV_HOST;
|
||||
|
||||
export default defineConfig({
|
||||
/** Tauri 패키지 앱 — 절대 경로(/assets) 사용 시 빈 화면 */
|
||||
base: './',
|
||||
/** sockjs-client 등 Node 전역 참조 — Tauri WebView에는 global 없음 */
|
||||
define: {
|
||||
global: 'globalThis',
|
||||
/** desktop은 항상 exdev 서버 (localhost 금지) */
|
||||
'import.meta.env.VITE_API_BASE_URL': JSON.stringify('https://exdev.co.kr/api'),
|
||||
__DESKTOP_CLIENT__: 'true',
|
||||
},
|
||||
envDir: __dirname,
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
dedupe: ['react', 'react-dom', 'lightweight-charts'],
|
||||
alias: {
|
||||
'@goldenchart/shared': sharedRoot,
|
||||
'@frontend': frontendRoot,
|
||||
'@frontend/utils/backendApi': path.resolve(sharedRoot, 'api/backendApi.ts'),
|
||||
[path.resolve(frontendRoot, 'utils/backendApi.ts')]: path.resolve(
|
||||
sharedRoot,
|
||||
'api/backendApi.ts',
|
||||
),
|
||||
},
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: ['react', 'react-dom', '@stomp/stompjs', 'sockjs-client'],
|
||||
esbuildOptions: {
|
||||
define: {
|
||||
global: 'globalThis',
|
||||
},
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
input: {
|
||||
main: path.resolve(__dirname, 'index.html'),
|
||||
widget: path.resolve(__dirname, 'widget.html'),
|
||||
},
|
||||
},
|
||||
},
|
||||
clearScreen: false,
|
||||
server: {
|
||||
port: 5175,
|
||||
strictPort: true,
|
||||
host: host || false,
|
||||
hmr: host
|
||||
? { protocol: 'ws', host, port: 5176 }
|
||||
: undefined,
|
||||
watch: {
|
||||
ignored: ['**/src-tauri/**'],
|
||||
},
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
'/upbit-api': {
|
||||
target: 'https://api.upbit.com',
|
||||
changeOrigin: true,
|
||||
rewrite: p => p.replace(/^\/upbit-api/, ''),
|
||||
},
|
||||
'/upbit-ws': {
|
||||
target: 'wss://api.upbit.com',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
rewrite: () => '/websocket/v1',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user