import { defineConfig } from 'vite'; import path from 'path'; // @ts-ignore - vite-plugin-wasm type definitions issue import wasm from 'vite-plugin-wasm'; import topLevelAwait from 'vite-plugin-top-level-await'; export default defineConfig({ optimizeDeps: { include: [], // Exclude heavy dependencies from pre-bundling exclude: ['pkg/sdk_client.js'] }, plugins: [ wasm(), topLevelAwait() ], build: { outDir: 'dist', target: 'esnext', minify: true, // Enable minification to reduce size rollupOptions: { input: { index: path.resolve(__dirname, 'index.html'), 'wallet-setup': path.resolve(__dirname, 'src/pages/wallet-setup/wallet-setup.html'), 'security-setup': path.resolve(__dirname, 'src/pages/security-setup/security-setup.html'), 'birthday-setup': path.resolve(__dirname, 'src/pages/birthday-setup/birthday-setup.html'), 'block-sync': path.resolve(__dirname, 'src/pages/block-sync/block-sync.html'), 'pairing': path.resolve(__dirname, 'src/pages/pairing/pairing.html'), 'home': path.resolve(__dirname, 'src/pages/home/home.html'), 'iframe-home': path.resolve(__dirname, 'src/pages/home/iframe-home.html'), 'account': path.resolve(__dirname, 'src/pages/account/account.html'), 'iframe-pairing': path.resolve(__dirname, 'src/pages/iframe-pairing.html'), }, output: { manualChunks: { // Split WebAssembly into separate chunk 'wasm': ['pkg/sdk_client.js'] } } } }, resolve: { alias: { '@': '/src', }, extensions: ['.ts', '.tsx', '.js'], }, server: { fs: { cachedChecks: false, }, port: 3004, host: '0.0.0.0', allowedHosts: [ 'dev3.4nkweb.com', 'localhost', '127.0.0.1', '31.33.24.235' ], proxy: { '/storage': { target: 'https://dev3.4nkweb.com', changeOrigin: true, secure: false, rewrite: (path) => path.replace(/^\/storage/, '/storage'), configure: (proxy, _options) => { proxy.on('error', (err, _req, _res) => { console.log('proxy error', err); }); proxy.on('proxyReq', (_proxyReq, req, _res) => { console.log('Sending Request:', req.method, req.url); }); proxy.on('proxyRes', (proxyRes, req, _res) => { console.log('Received Response:', proxyRes.statusCode, req.url); }); } } } }, });