Skip to content

Commit 19fa65f

Browse files
Copilothotlong
andcommitted
fix: skip memory-hungry plugins and src aliases in Vercel/CI builds
On Vercel/CI, the turbo pipeline already builds every workspace package to dist/ before Vite runs. This change: 1. Skips gzip/brotli compression plugins (Vercel CDN handles this) 2. Skips rollup-plugin-visualizer (not needed in CI) 3. Removes resolve.alias src/ overrides so Vite uses pre-built dist/ Together these reduce Vite/Rollup peak memory by ~2 GB, resolving the OOM failures on Vercel without needing --concurrency or NODE_OPTIONS workarounds. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 860a00c commit 19fa65f

1 file changed

Lines changed: 34 additions & 24 deletions

File tree

apps/console/vite.config.ts

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ function preloadCriticalChunks(): Plugin {
4040
// auto-mount slug. Override with VITE_BASE_PATH only if deploying standalone.
4141
const 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/
4452
export 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: [/\.(br)$/, /\.(gz)$/],
61-
threshold: 1024,
62-
}),
63-
// Brotli compression for modern browsers
64-
compression({
65-
algorithm: 'brotliCompress',
66-
exclude: [/\.(br)$/, /\.(gz)$/],
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: [/\.(br)$/, /\.(gz)$/],
71+
threshold: 1024,
72+
}),
73+
compression({
74+
algorithm: 'brotliCompress',
75+
exclude: [/\.(br)$/, /\.(gz)$/],
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

Comments
 (0)