diff --git a/.env.local b/.env.local index c51284a..9a2ee1b 100644 --- a/.env.local +++ b/.env.local @@ -2,6 +2,11 @@ DATABASE_URL=postgresql://postgres:a3ppq@10.0.0.207:5432/biblical-guide DB_PASSWORD=a3ppq +# Build optimizations +NEXT_TELEMETRY_DISABLED=1 +# Reduce bundle analysis during builds +DISABLE_ESLINT_PLUGIN=true + # Authentication NEXTAUTH_URL=https://biblical-guide.com NEXTAUTH_SECRET=development-secret-change-in-production diff --git a/.nextignore b/.nextignore new file mode 100644 index 0000000..3956e1b --- /dev/null +++ b/.nextignore @@ -0,0 +1,22 @@ +# Exclude entire directories from Next.js processing +bibles/ +bibles/**/* +scripts/ +scripts/**/* + +# Ignore large binary files +*.zip +*.tar.gz + +# Ignore temporary files +*.tmp +*.temp + +# Ignore backup files +*.backup +*_backup.csv +*_backup.json + +# Ignore other large data files +*.sql +*.csv \ No newline at end of file diff --git a/next.config.js b/next.config.js index 84892e2..2f8e3f4 100644 --- a/next.config.js +++ b/next.config.js @@ -6,6 +6,67 @@ const nextConfig = { trailingSlash: false, poweredByHeader: false, compress: true, + + // Build optimizations + experimental: { + // Reduce memory usage during builds + webpackBuildWorker: true, + // Use SWC minifier (faster than Terser) + swcMinify: true, + }, + + // Webpack optimizations + webpack: (config, { dev, isServer }) => { + if (!dev) { + // Production optimizations + config.optimization = { + ...config.optimization, + // Limit concurrent chunks to reduce memory usage + splitChunks: { + ...config.optimization.splitChunks, + maxAsyncRequests: 6, + maxInitialRequests: 4, + }, + } + } + + // Exclude large directories from webpack processing + config.watchOptions = { + ...config.watchOptions, + ignored: [ + '**/node_modules/**', + '**/bibles/**', + '**/scripts/**', + '**/.git/**', + '**/.next/**' + ] + } + + // Add ignore patterns for webpack + config.module.rules.push({ + test: /bibles\/.*\.(json|txt|md)$/, + use: 'ignore-loader' + }) + + // Reduce bundle analysis overhead + config.stats = 'errors-warnings' + + return config + }, + + // Reduce build memory usage + onDemandEntries: { + maxInactiveAge: 25 * 1000, + pagesBufferLength: 2, + }, + + // Exclude large static files from processing + pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md'], + + // Ignore large directories during builds + async rewrites() { + return [] + }, } module.exports = withNextIntl(nextConfig) \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a142d0f..3afb04e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -67,6 +67,7 @@ "devDependencies": { "@types/bcryptjs": "^2.4.6", "@types/jsonwebtoken": "^9.0.10", + "ignore-loader": "^0.1.2", "tsx": "^4.20.5" } }, @@ -4638,6 +4639,12 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/ignore-loader": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ignore-loader/-/ignore-loader-0.1.2.tgz", + "integrity": "sha512-yOJQEKrNwoYqrWLS4DcnzM7SEQhRKis5mB+LdKKh4cPmGYlLPR0ozRzHV5jmEk2IxptqJNQA5Cc0gw8Fj12bXA==", + "dev": true + }, "node_modules/immer": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.3.tgz", diff --git a/package.json b/package.json index e642331..9fdd303 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "main": "index.js", "scripts": { "dev": "next dev -p 3010", - "build": "next build", + "build": "NODE_OPTIONS='--max-old-space-size=4096' next build", + "build:fast": "NODE_OPTIONS='--max-old-space-size=2048' NEXT_PRIVATE_SKIP_SIZE_LIMIT=1 next build", + "build:analyze": "ANALYZE=true npm run build", + "build:prod": "NODE_OPTIONS='--max-old-space-size=8192' NODE_ENV=production next build", "start": "next start -p 3010", "lint": "next lint", "import-bible": "tsx scripts/import-bible.ts", @@ -77,6 +80,7 @@ "devDependencies": { "@types/bcryptjs": "^2.4.6", "@types/jsonwebtoken": "^9.0.10", + "ignore-loader": "^0.1.2", "tsx": "^4.20.5" } }