dify/web/scripts
Stephen Zhou 6d0e36479b
refactor(i18n): use JSON with flattened key and namespace (#30114)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-29 14:52:32 +08:00
..
README.md feat: Optimize Docker build process by adding script to remove unnecessary files (#24450) 2025-08-25 14:44:29 +08:00
analyze-component.js refactor(web): drop swr and migrate share/chat hooks to tanstack query (#30232) 2025-12-29 14:04:01 +08:00
analyze-i18n-diff.ts refactor(i18n): use JSON with flattened key and namespace (#30114) 2025-12-29 14:52:32 +08:00
component-analyzer.js refactor(web): drop swr and migrate share/chat hooks to tanstack query (#30232) 2025-12-29 14:04:01 +08:00
copy-and-start.mjs chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
generate-icons.js chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
optimize-standalone.js chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
refactor-component.js refactor(web): drop swr and migrate share/chat hooks to tanstack query (#30232) 2025-12-29 14:04:01 +08:00

README.md

Production Build Optimization Scripts

optimize-standalone.js

This script removes unnecessary development dependencies from the Next.js standalone build output to reduce the production Docker image size.

What it does

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:

  1. Next.js includes jest-worker in its compiled dependencies
  2. terser-webpack-plugin (used by Next.js for minification) depends on jest-worker
  3. pnpm's dependency resolution creates symlinks to jest-worker in various locations

Usage

The script is automatically run during Docker builds via the build:docker npm script:

# Docker build (removes jest-worker after build)
pnpm build:docker

To run the optimization manually:

node scripts/optimize-standalone.js

What gets removed

  • node_modules/.pnpm/next@*/node_modules/next/dist/compiled/jest-worker
  • node_modules/.pnpm/terser-webpack-plugin@*/node_modules/jest-worker (symlinks)
  • node_modules/.pnpm/jest-worker@* (actual packages)

Impact

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.