Problem:
- Turbopack file tracing caused by process.cwd() in upload.ts
- Google fonts download failures in CI network environment
- Module resolution errors for @vercel/turbopack-next
Solutions:
- Add turbopackIgnore comment to process.cwd() call
- Temporarily disable Google fonts to avoid network dependencies
- Use system fonts as fallback for CI builds
- Switch to node:20-alpine for faster SSH installation
- Add SSH debugging information
This should resolve the 493 build errors and enable successful CI deployment.
The real root cause of CI build failures was NOT Turbopack, but
Resend initialization at module level without API key.
Problem:
- Resend was initialized at module level: const resend = new Resend(process.env.RESEND_API_KEY)
- During build, Next.js collects page data and imports all modules
- If RESEND_API_KEY is not set, Resend throws error: 'Missing API key'
- This caused build to fail with 'Failed to collect page data for /api/contact'
Solution:
- Implement lazy initialization pattern for Resend
- Only initialize Resend when actually needed (when sending emails)
- Add proper error handling if API key is missing
Changes:
- src/app/api/contact/route.ts: Add getResend() function with lazy init
- src/app/(marketing)/contact/actions.ts: Add getResend() function with lazy init
This allows the build to succeed even without RESEND_API_KEY in CI,
while still requiring it at runtime when actually sending emails.
Extract all path.join operations into dedicated functions to prevent
Turbopack from tracing dynamic paths.
Changes:
- Add buildUploadPath() function
- Add buildFilePath() function
- Replace direct path.join calls with function calls
- Remove unused uploadBaseDir variable
Results:
- Turbopack warnings: 4 → 2
- Build time: 14.3s → 7.5s
- Build succeeds without hanging
This prevents Turbopack from creating overly broad file patterns
that match the entire project directory.
The Turbopack build was matching 29409+ files due to dynamic path
resolution in upload.ts. This caused the CI build to hang.
Root cause: Turbopack traces process.cwd() and creates overly broad
file patterns, leading to performance issues.
Solution: Extract process.cwd() into a separate function to prevent
Turbopack from tracing the entire project directory.
This fix reduces build time and prevents CI timeout issues.
- Move CI/CD configs to config/ci/ directory
- Reorganize scripts into categorized directories (deployment, monitoring, testing, utils)
- Consolidate documentation into docs/ directory with proper structure
- Update linting and testing configurations
- Remove obsolete test reports and performance summaries
- Add new documentation for code quality tools and contact form security
- Improve project organization and maintainability
- Fix lint-staged config to only lint JS/TS files
- Disable react/react-in-jsx-scope rule for Next.js compatibility
- Ignore scripts and test config directories in ESLint
- Create public config API for frontend consumption
- Add configuration fetching to homepage
- Implement module show/hide logic based on config
- Add support for Services items filtering
- Add support for Products featured products and pricing display
- Add support for News display count, categories, and sort order
- Fix table name from 'configs' to 'siteConfig' in API route
- Update type definitions for proper TypeScript support
- Update admin layout title from 'CMS' to '后台管理'
- Update terms page service description from 'CMS' to '后台管理系统'
- Improve Chinese localization consistency
- Remove server-side grouping logic from API response
- Return flat array instead of grouped object
- Fix data structure mismatch between API and frontend
- Resolve TypeError when accessing admin settings page
- Disable all experimental features to fix React 19 and Next.js 16 compatibility
- Fix TypeScript error in check-permission.ts (role property issue)
- Add test script for Contact page validation
- Use production mode to avoid HMR issues completely