Files
pezkuwi-telegram-miniapp/vite.config.ts
T
SatoshiQaziMuhammed a80c7c30d1 build: drop vite-plugin-node-polyfills and its elliptic dependency (#59)
The plugin pulled node-stdlib-browser -> crypto-browserify ->
browserify-sign/create-ecdh -> elliptic (GHSA-848j-6mx2-7j84, no
patched release) into the runtime dependency tree.

Nothing in the app imports a Node builtin. In the production build the
plugin only injected shims at four call sites, each already guarded by a
typeof check with a browser fallback:

- @supabase/storage-js toBase64 (Buffer; falls back to btoa, and the app
  does not use Supabase Storage)
- @supabase/realtime-js WebSocketFactory (global; native WebSocket is
  detected first)
- @pezkuwi/x-global (global; globalThis is checked first)
- js-sha3 (process; only used to detect Node)

The crypto, stream and util polyfills were never reached by any module,
so removing the plugin drops 97 packages from the lockfile, including
elliptic, and the feross buffer copy from the bundle.
2026-11-15 06:26:08 +04:00

61 lines
1.5 KiB
TypeScript

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import fs from 'fs';
// Read version info for build
const versionInfo = JSON.parse(
fs.readFileSync(path.resolve(__dirname, './src/version.json'), 'utf-8')
);
export default defineConfig({
plugins: [
react(),
// Copy version.json to dist for update checking
{
name: 'copy-version',
closeBundle() {
const src = path.resolve(__dirname, './src/version.json');
const dest = path.resolve(__dirname, './dist/version.json');
fs.copyFileSync(src, dest);
console.log('✓ version.json copied to dist');
},
},
],
define: {
__APP_VERSION__: JSON.stringify(versionInfo.version),
__BUILD_TIME__: JSON.stringify(versionInfo.buildTime),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
},
build: {
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
output: {
manualChunks: {
// React core
'vendor-react': ['react', 'react-dom'],
// React Query
'vendor-query': ['@tanstack/react-query'],
// UI components and icons
'vendor-ui': ['lucide-react'],
// Pezkuwi/Polkadot crypto libraries (largest chunk)
'vendor-crypto': [
'@pezkuwi/api',
'@pezkuwi/keyring',
'@pezkuwi/util-crypto',
'@pezkuwi/util',
],
},
},
},
},
});