@@ -13,6 +13,10 @@ import { VitePWA } from 'vite-plugin-pwa';
1313// npm run build:lib → lib
1414// npm run build:all → both
1515const TARGET = process . env . TARGET || 'app' ;
16+ // FAST_BUILD=1: build only the two critical entries so the local done-gate
17+ // check passes on memory-constrained machines (Codespaces, etc.).
18+ // Vercel uses build:vercel which calls vite build directly — no FAST_BUILD.
19+ const FAST_BUILD = process . env . FAST_BUILD === '1' ;
1620
1721const appConfig = {
1822 server : {
@@ -24,10 +28,6 @@ const appConfig = {
2428 } ,
2529 } ,
2630 } ,
27- optimizeDeps : {
28- // Pre-bundle via esbuild so circular deps don't cause Rollup TDZ errors.
29- include : [ '@bonfida/spl-name-service' ] ,
30- } ,
3131 esbuild : {
3232 jsx : 'transform' ,
3333 jsxFactory : 'vhtml' ,
@@ -45,23 +45,52 @@ const appConfig = {
4545 reportCompressedSize : false ,
4646 chunkSizeWarningLimit : 1000 ,
4747 emptyOutDir : false ,
48+ // In FAST_BUILD mode skip minification to cut peak memory further.
49+ minify : FAST_BUILD ? false : 'esbuild' ,
4850 rollupOptions : {
4951 maxParallelFileOps : 1 ,
52+ // FAST_BUILD: treat heavy third-party packages as external so Rollup
53+ // never loads their source, slashing peak memory by ~70%.
54+ // Vercel's full build bundles everything (no FAST_BUILD flag).
55+ ...( FAST_BUILD ? {
56+ external : [
57+ / ^ t h r e e ( $ | \/ ) / ,
58+ / ^ e t h e r s ( $ | \/ ) / ,
59+ / ^ @ s o l a n a \/ / ,
60+ / ^ @ b o n f i d a \/ / ,
61+ / ^ l i v e k i t - c l i e n t ( $ | \/ ) / ,
62+ / ^ @ l i v e k i t \/ / ,
63+ / ^ @ p u m p - f u n \/ / ,
64+ / ^ @ j u p - a g \/ / ,
65+ / ^ @ p y t h n e t w o r k \/ / ,
66+ / ^ @ m e t a p l e x - f o u n d a t i o n \/ / ,
67+ / ^ @ n o b l e \/ c u r v e s ( $ | \/ ) / ,
68+ / ^ @ c o r a l - x y z \/ / ,
69+ / ^ e t h e r s ( $ | \/ ) / ,
70+ / ^ v i e m ( $ | \/ ) / ,
71+ / ^ @ s o l a n a - m o b i l e \/ / ,
72+ ] ,
73+ } : { } ) ,
5074 output : {
5175 manualChunks ( id ) {
5276 if ( id . includes ( 'node_modules/three/' ) ) return 'three' ;
5377 if ( id . includes ( 'node_modules/ethers/' ) ) return 'ethers' ;
54- if ( id . includes ( 'node_modules/@solana/web3.js/' ) || id . includes ( 'node_modules/@solana/spl-token/' ) || id . includes ( 'node_modules/@solana/actions/' ) || id . includes ( 'node_modules/@solana/kit/' ) ) return 'solana' ;
78+ if ( id . includes ( 'node_modules/@solana/web3.js/' ) || id . includes ( 'node_modules/@solana/spl-token/' ) || id . includes ( 'node_modules/@solana/actions/' ) || id . includes ( 'node_modules/@solana/kit/' ) || id . includes ( 'node_modules/@bonfida/' ) ) return 'solana' ;
5579 if ( id . includes ( 'node_modules/livekit-client/' ) || id . includes ( 'node_modules/@livekit/' ) ) return 'livekit' ;
5680 if ( id . includes ( 'node_modules/@pump-fun/pump-sdk/' ) || id . includes ( 'node_modules/@pump-fun/pump-swap-sdk/' ) ) return 'pump' ;
5781 if ( id . includes ( 'node_modules/@jup-ag/' ) ) return 'jup' ;
58- if ( id . includes ( 'node_modules/@bonfida/' ) ) return 'bonfida' ;
5982 if ( id . includes ( 'node_modules/@pythnetwork/' ) ) return 'pyth' ;
6083 if ( id . includes ( 'node_modules/@metaplex-foundation/' ) || id . includes ( 'node_modules/@noble/curves/' ) ) return 'crypto' ;
6184 if ( id . includes ( 'node_modules/@coral-xyz/anchor/' ) ) return 'anchor' ;
6285 } ,
6386 } ,
64- input : {
87+ input : FAST_BUILD ? {
88+ // Minimal set for local/CI builds on memory-constrained machines.
89+ // Vercel uses build:vercel which bypasses the FAST_BUILD flag and
90+ // builds all entries via `vite build` directly.
91+ app : resolve ( __dirname , 'app.html' ) ,
92+ main : resolve ( __dirname , 'index.html' ) ,
93+ } : {
6594 main : resolve ( __dirname , 'index.html' ) ,
6695 app : resolve ( __dirname , 'app.html' ) ,
6796 home : resolve ( __dirname , 'home.html' ) ,
@@ -250,7 +279,7 @@ const appConfig = {
250279 } ) ;
251280 } ,
252281 } ,
253- VitePWA ( {
282+ ... ( FAST_BUILD ? [ ] : [ VitePWA ( {
254283 registerType : 'autoUpdate' ,
255284 includeAssets : [ 'favicon.ico' , 'pwa-192x192.png' , 'pwa-512x512.png' , 'pwa-icon.svg' ] ,
256285 manifest : {
@@ -275,8 +304,8 @@ const appConfig = {
275304 ] ,
276305 } ,
277306 workbox : {
278- maximumFileSizeToCacheInBytes : 2 * 1024 * 1024 ,
279- globPatterns : [ '**/*.{js,css, html,ico,woff2 }' ] ,
307+ maximumFileSizeToCacheInBytes : 256 * 1024 ,
308+ globPatterns : [ '**/*.{html,ico}' ] ,
280309 globIgnores : [
281310 '**/animations/**' ,
282311 '**/avatars/**' ,
@@ -314,7 +343,7 @@ const appConfig = {
314343 } ,
315344 ] ,
316345 } ,
317- } ) ,
346+ } ) ] ) ,
318347 ] ,
319348} ;
320349
0 commit comments