@@ -40,6 +40,14 @@ function preloadCriticalChunks(): Plugin {
4040// auto-mount slug. Override with VITE_BASE_PATH only if deploying standalone.
4141const basePath = process . env . VITE_BASE_PATH || '/console/' ;
4242
43+ // On Vercel/CI the turbo pipeline already builds every workspace package to
44+ // dist/ before Vite runs, so we can skip the memory-hungry src/ aliases and
45+ // let Vite resolve each @object -ui/* package through its normal package.json
46+ // "exports" → dist/. We also skip the compression and visualizer plugins
47+ // because the Vercel CDN handles gzip/brotli automatically and bundle analysis
48+ // is not needed during CI builds. Together this reduces peak memory by ~2 GB.
49+ const isCI = ! ! ( process . env . VERCEL || process . env . CI ) ;
50+
4351// https://vitejs.dev/config/
4452export default defineConfig ( {
4553 base : basePath ,
@@ -54,29 +62,33 @@ export default defineConfig({
5462 react ( ) ,
5563 // Inject <link rel="modulepreload"> for critical chunks
5664 preloadCriticalChunks ( ) ,
57- // Gzip compression for production assets
58- compression ( {
59- algorithm : 'gzip' ,
60- exclude : [ / \. ( b r ) $ / , / \. ( g z ) $ / ] ,
61- threshold : 1024 ,
62- } ) ,
63- // Brotli compression for modern browsers
64- compression ( {
65- algorithm : 'brotliCompress' ,
66- exclude : [ / \. ( b r ) $ / , / \. ( g z ) $ / ] ,
67- threshold : 1024 ,
68- } ) ,
69- // Bundle analysis (generates stats.html in dist/)
70- visualizer ( {
71- filename : 'dist/stats.html' ,
72- gzipSize : true ,
73- brotliSize : true ,
74- open : false ,
75- } ) ,
65+ // Gzip/Brotli compression & bundle visualizer are skipped on Vercel/CI to
66+ // reduce memory usage — Vercel's CDN compresses assets automatically.
67+ ...( ! isCI ? [
68+ compression ( {
69+ algorithm : 'gzip' ,
70+ exclude : [ / \. ( b r ) $ / , / \. ( g z ) $ / ] ,
71+ threshold : 1024 ,
72+ } ) ,
73+ compression ( {
74+ algorithm : 'brotliCompress' ,
75+ exclude : [ / \. ( b r ) $ / , / \. ( g z ) $ / ] ,
76+ threshold : 1024 ,
77+ } ) ,
78+ visualizer ( {
79+ filename : 'dist/stats.html' ,
80+ gzipSize : true ,
81+ brotliSize : true ,
82+ open : false ,
83+ } ) ,
84+ ] : [ ] ) ,
7685 ] ,
7786 resolve : {
7887 extensions : [ '.mjs' , '.js' , '.mts' , '.ts' , '.jsx' , '.tsx' , '.json' ] ,
79- alias : {
88+ // In CI/Vercel builds, all workspace packages are pre-built to dist/ by
89+ // turbo so Vite resolves them through package.json "exports". During local
90+ // dev, src/ aliases give us instant HMR without a prior build step.
91+ alias : isCI ? { } : {
8092 '@object-ui/components' : path . resolve ( __dirname , '../../packages/components/src' ) ,
8193 '@object-ui/core' : path . resolve ( __dirname , '../../packages/core/src' ) ,
8294 '@object-ui/fields' : path . resolve ( __dirname , '../../packages/fields/src' ) ,
@@ -93,8 +105,8 @@ export default defineConfig({
93105 '@object-ui/collaboration' : path . resolve ( __dirname , '../../packages/collaboration/src' ) ,
94106 '@object-ui/tenant' : path . resolve ( __dirname , '../../packages/tenant/src' ) ,
95107 '@object-ui/i18n' : path . resolve ( __dirname , '../../packages/i18n/src' ) ,
96-
97- // Missing Plugin Aliases
108+
109+ // Plugin Aliases
98110 '@object-ui/plugin-aggrid' : path . resolve ( __dirname , '../../packages/plugin-aggrid/src' ) ,
99111 '@object-ui/plugin-calendar' : path . resolve ( __dirname , '../../packages/plugin-calendar/src' ) ,
100112 '@object-ui/plugin-charts' : path . resolve ( __dirname , '../../packages/plugin-charts/src' ) ,
@@ -108,8 +120,6 @@ export default defineConfig({
108120 '@object-ui/plugin-markdown' : path . resolve ( __dirname , '../../packages/plugin-markdown/src' ) ,
109121 '@object-ui/plugin-timeline' : path . resolve ( __dirname , '../../packages/plugin-timeline/src' ) ,
110122 '@object-ui/plugin-view' : path . resolve ( __dirname , '../../packages/plugin-view/src' ) ,
111-
112-
113123 } ,
114124 } ,
115125 optimizeDeps : {
0 commit comments