mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Replace manual BackButton management with official @telegram-apps/react-router-integration to fix navigation issues (back button cycling and double-click). Changes: - Migrate from @tma.js/sdk-react to @telegram-apps/sdk-react - Downgrade react-router-dom to v6 for package compatibility - Add AppWithNavigator component with Telegram navigator integration - Use browser history mode (hashMode: null) to prevent hash URLs - Add multi-level platform detection (user data, platform, version) - Add try-catch error handling for navigator attach/detach - Simplify useBackButton hook to no-op (navigator handles automatically) - Update vite config with new Telegram packages The navigator automatically manages BackButton based on router history, falling back to BrowserRouter in regular browser environment.
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import path from 'path';
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
// Base path - use '/' for standalone Docker deployment
|
|
// Change to '/cabinet/' if serving from a sub-path
|
|
base: '/',
|
|
server: {
|
|
port: 5173,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
// Strip /api prefix: /api/cabinet/auth -> /cabinet/auth
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: false,
|
|
chunkSizeWarningLimit: 550,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
|
'vendor-query': ['@tanstack/react-query'],
|
|
'vendor-i18n': ['i18next', 'react-i18next', 'i18next-browser-languagedetector'],
|
|
'vendor-motion': ['framer-motion'],
|
|
'vendor-radix': [
|
|
'@radix-ui/react-dialog',
|
|
'@radix-ui/react-tooltip',
|
|
'@radix-ui/react-select',
|
|
'@radix-ui/react-popover',
|
|
'@radix-ui/react-dropdown-menu',
|
|
'@radix-ui/react-tabs',
|
|
'@radix-ui/react-switch',
|
|
'@radix-ui/react-alert-dialog',
|
|
'@radix-ui/react-slot',
|
|
'@radix-ui/react-visually-hidden',
|
|
],
|
|
'vendor-dnd': ['@dnd-kit/core', '@dnd-kit/sortable', '@dnd-kit/utilities'],
|
|
'vendor-telegram': [
|
|
'@telegram-apps/sdk',
|
|
'@telegram-apps/sdk-react',
|
|
'@telegram-apps/react-router-integration',
|
|
],
|
|
'vendor-utils': [
|
|
'axios',
|
|
'zustand',
|
|
'clsx',
|
|
'tailwind-merge',
|
|
'class-variance-authority',
|
|
'dompurify',
|
|
],
|
|
'vendor-lottie': ['@lottiefiles/dotlottie-react'],
|
|
'vendor-webgl': ['ogl'],
|
|
'vendor-cmdk': ['cmdk'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|