Files
pwap/web/vite.config.ts
T
pezkuwichain 27da237b38 fix(critical): resolve 4 production blockers
CRITICAL FIXES:
1.  Hardcoded endpoint replaced with env variable
   - App.tsx: Uses VITE_WS_ENDPOINT from .env
   - PolkadotContext: Fallback endpoints support
   - .env & .env.production: Added VITE_WS_ENDPOINT config

2.  Console statements guarded (433 instances)
   - All console.log/warn/error wrapped with import.meta.env.DEV
   - Production builds now clean (no console output)

3.  ESLint error fixed
   - vite.config.ts: Removed unused 'mode' parameter
   - 0 errors, 27 warnings (non-critical exhaustive-deps)

4.  Bundle optimization implemented
   - Route-based code splitting with React.lazy + Suspense
   - Manual chunks: polkadot (968KB), vendor (160KB), ui (112KB), i18n (60KB)
   - Total gzip: 843KB → 650KB (23% reduction)
   - Individual route chunks for optimal loading

PRODUCTION READY IMPROVEMENTS:
- Endpoint configuration: Environment-based with fallbacks
- Performance: 23% bundle size reduction
- Code quality: Clean production builds
- User experience: Loading states for route transitions

Build verified: ✓ 0 errors
Bundle analysis: ✓ Optimized chunks
Production deployment: READY

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 06:26:48 +03:00

68 lines
2.2 KiB
TypeScript

/// <reference types="vitest" />
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react-swc";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig(() => ({
test: {
globals: true,
environment: 'jsdom',
setupFiles: './src/tests/setup.ts',
},
server: {
host: "::",
port: 8082,
strictPort: false, // Allow automatic port selection if 8082 is busy
hmr: {
protocol: 'ws',
host: 'localhost',
},
watch: {
usePolling: true,
},
},
plugins: [
react()
].filter(Boolean),
define: {
'global': 'globalThis',
'process.env': {}
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@pezkuwi/i18n": path.resolve(__dirname, "../shared/i18n"),
"@pezkuwi/lib": path.resolve(__dirname, "../shared/lib"),
"@pezkuwi/utils": path.resolve(__dirname, "../shared/utils"),
"@pezkuwi/theme": path.resolve(__dirname, "../shared/theme"),
"@pezkuwi/types": path.resolve(__dirname, "../shared/types"),
"@pezkuwi/components": path.resolve(__dirname, "../shared/components"),
"@shared": path.resolve(__dirname, "../shared"),
},
dedupe: ['react', 'lucide-react', 'sonner', '@polkadot/util-crypto', '@polkadot/util', '@polkadot/api', '@polkadot/extension-dapp', '@polkadot/keyring'],
},
optimizeDeps: {
include: ['@polkadot/util-crypto', '@polkadot/util', '@polkadot/api', '@polkadot/extension-dapp', '@polkadot/keyring'],
esbuildOptions: {
define: {
global: 'globalThis'
}
}
},
build: {
rollupOptions: {
output: {
manualChunks: {
'polkadot': ['@polkadot/api', '@polkadot/extension-dapp', '@polkadot/keyring', '@polkadot/util', '@polkadot/util-crypto'],
'vendor': ['react', 'react-dom', 'react-router-dom'],
'ui': ['@radix-ui/react-dialog', '@radix-ui/react-dropdown-menu', '@radix-ui/react-select', '@radix-ui/react-tabs', '@radix-ui/react-toast'],
'forms': ['react-hook-form', '@hookform/resolvers', 'zod'],
'i18n': ['i18next', 'react-i18next', 'i18next-browser-languagedetector']
}
}
},
chunkSizeWarningLimit: 600
},
assetsInclude: ['**/*.json'],
}));