Please let me fix this issue. Since I increased the heap size on local, it works fine, but not working on vercel.
Build script
"build": "cross-env NODE_OPTIONS=--max_old_space_size=65536 vite build"
My current vite config
import { resolve } from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
import { visualizer } from 'rollup-plugin-visualizer'
// https://github.com/vitejs/vite/discussions/2785#discussioncomment-7803485
export default defineConfig({
server: {
port: 3000,
},
plugins: [
nodePolyfills({
include: ['path', 'stream', 'util'],
exclude: ['http'],
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
protocolImports: true,
}),
react(),
visualizer({
filename: 'bundle-analysis.html',
open: true, // Opens the report after build
}),
],
// NOTE: Have to be added to fix: Uncaught ReferenceError: process & global is not defined
define: {
'process.env': {},
'process.browser': true,
global: 'globalThis',
},
resolve: {
alias: {
assets: resolve('src/assets'),
components: resolve('src/components'),
context: resolve('src/context'),
'fortuna-sdk': resolve('src/fortuna-sdk'),
helpers: resolve('src/helpers'),
hooks: resolve('src/hooks'),
services: resolve('src/services'),
settings: resolve('src/settings'),
store: resolve('src/store'),
views: resolve('src/views'),
crypto: 'crypto-browserify',
'node:crypto': 'crypto-browserify',
http: 'stream-http',
https: 'https-browserify',
vm: 'vm-browserify',
},
},
build: {
reportCompressedSize: true,
sourcemap: false,
minify: false,
rollupOptions: {
treeshake: true,
maxParallelFileOps: 1,
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id
.toString()
.split('node_modules/')[1]
.split('/')[0]
.toString()
}
},
},
},
},
esbuild: {
target: 'es2022',
logOverride: { 'this-is-undefined-in-esm': 'silent' },
},
optimizeDeps: {
esbuildOptions: {
// NOTE: Have to be added to fix: Uncaught ReferenceError: global is not defined
define: { global: 'globalThis' },
},
},
})
▲ Build system report
• At least one "Out of Memory" ("OOM") event was detected during the build.
• This occurs when processes or applications running during the build completely fill up the available memory (RAM) in the build container. When this happens, the build container terminates one of the processes during the build with a SIGKILL signal.
• Read this troubleshooting guide for more information: https://vercel.link/troubleshoot-build-errors
• The build container has plenty of disk space left
• Folder sizes on disk:
‣ Input source code: 4 MB
‣ Build cache: 1318 MB
‣ Output files: 1 MB
‣ Node modules: 1118 MB
• No files larger than 100 MB detected on disk