Add bundle analyzer configuration

Configure @next/bundle-analyzer for production bundle analysis:

**Changes:**
- Install @next/bundle-analyzer package
- Update next.config.mjs to wrap config with bundle analyzer
- Add npm script `build:analyze` to run build with ANALYZE=true
- Bundle analyzer only enabled when ANALYZE=true environment variable is set

**Usage:**
```bash
# Run build with bundle analysis
npm run build:analyze

# Opens interactive bundle visualization in browser
# Shows chunk sizes, module dependencies, and optimization opportunities
```

**Note:** Kept Mastodon feed as Client Component (not Server Component)
because formatRelativeTime() uses `new Date()` which requires dynamic
rendering. Converting to Server Component would prevent static generation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 22:00:02 +08:00
parent 0bb3ee40c6
commit ba60d49fc6
5 changed files with 324 additions and 133 deletions

View File

@@ -7,6 +7,7 @@
"dev": "concurrently \"contentlayer2 dev\" \"next dev --turbo\"",
"sync-assets": "node scripts/sync-assets.mjs",
"build": "npm run sync-assets && contentlayer2 build && next build && npx pagefind --site .next && rm -rf public/_pagefind && cp -r .next/pagefind public/_pagefind",
"build:analyze": "ANALYZE=true npm run build",
"start": "next start",
"lint": "next lint",
"contentlayer": "contentlayer build"
@@ -38,6 +39,7 @@
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^16.0.3",
"@tailwindcss/typography": "^0.5.19",
"@types/node": "^24.10.1",
"@types/react": "^19.2.5",