dify/web/scripts
Novice 89b76d6c33
Merge commit '657eeb65' into sandboxed-agent-rebase
Made-with: Cursor

# Conflicts:
#	api/core/agent/cot_chat_agent_runner.py
#	api/core/agent/fc_agent_runner.py
#	api/core/memory/token_buffer_memory.py
#	api/core/variables/segments.py
#	api/core/workflow/file/file_manager.py
#	api/core/workflow/nodes/agent/agent_node.py
#	api/core/workflow/nodes/llm/llm_utils.py
#	api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py
#	api/core/workflow/workflow_entry.py
#	api/factories/variable_factory.py
#	api/pyproject.toml
#	api/services/variable_truncator.py
#	api/uv.lock
#	web/app/components/app/app-publisher/index.tsx
#	web/app/components/app/overview/settings/index.tsx
#	web/app/components/apps/app-card.tsx
#	web/app/components/apps/index.tsx
#	web/app/components/apps/list.tsx
#	web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
#	web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
#	web/app/components/base/features/new-feature-panel/file-upload/setting-content.tsx
#	web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx
#	web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx
#	web/app/components/base/message-log-modal/index.tsx
#	web/app/components/base/switch/index.tsx
#	web/app/components/base/tab-slider-plain/index.tsx
#	web/app/components/explore/try-app/app-info/index.tsx
#	web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx
#	web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/required-switch.tsx
#	web/app/components/workflow/nodes/llm/panel.tsx
#	web/contract/router.ts
#	web/eslint-suppressions.json
#	web/i18n/fa-IR/workflow.json
2026-03-19 17:38:56 +08:00
..
analyze-component.js docs: relocate frontend docs for agents and human (#31714) 2026-01-29 17:58:10 +08:00
analyze-i18n-diff.ts fix(web): disable HTML escaping for form field validation messages (#31292) 2026-01-20 18:43:01 +08:00
check-i18n.js chore: i18n namespace refactor in package.json and add missing translations (#30324) 2025-12-29 20:59:11 +08:00
component-analyzer.js refactor(web): replace String.match() with RegExp.exec() for non-global regex (#32386) 2026-02-18 17:46:38 +09:00
copy-and-start.mjs chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
fetch-skill-templates.ts refactor(skill): remove tags/icons/categories, use kebab-case folder names 2026-01-30 16:10:19 +08:00
gen-doc-paths.ts refactor(web): replace String.match() with RegExp.exec() for non-global regex (#32386) 2026-02-18 17:46:38 +09:00
gen-icons.mjs chore: update knip config and include in CI (#30410) 2025-12-31 15:38:07 +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
README.md feat: Optimize Docker build process by adding script to remove unnecessary files (#24450) 2025-08-25 14:44:29 +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

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.