You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Production Build Optimization Scripts
  2. ## optimize-standalone.js
  3. This script removes unnecessary development dependencies from the Next.js standalone build output to reduce the production Docker image size.
  4. ### What it does
  5. The script specifically targets and removes `jest-worker` packages that are bundled with Next.js but not needed in production. These packages are included because:
  6. 1. Next.js includes jest-worker in its compiled dependencies
  7. 1. terser-webpack-plugin (used by Next.js for minification) depends on jest-worker
  8. 1. pnpm's dependency resolution creates symlinks to jest-worker in various locations
  9. ### Usage
  10. The script is automatically run during Docker builds via the `build:docker` npm script:
  11. ```bash
  12. # Docker build (removes jest-worker after build)
  13. pnpm build:docker
  14. ```
  15. To run the optimization manually:
  16. ```bash
  17. node scripts/optimize-standalone.js
  18. ```
  19. ### What gets removed
  20. - `node_modules/.pnpm/next@*/node_modules/next/dist/compiled/jest-worker`
  21. - `node_modules/.pnpm/terser-webpack-plugin@*/node_modules/jest-worker` (symlinks)
  22. - `node_modules/.pnpm/jest-worker@*` (actual packages)
  23. ### Impact
  24. Removing jest-worker saves approximately 36KB per instance from the production image. While this may seem small, it helps ensure production images only contain necessary runtime dependencies.