Skip to content

[Enhancement]: Optimize vendor chunk size via code splitting and manual chunks #656

Description

@vedxnt-10

Description

Currently, when running the production build, Vite produces a massive vendor chunk (dist/assets/vendor-*.js is over 2MB), which significantly exceeds the recommended 800kB limit. This negatively impacts the initial load time and performance of the application.

We need to optimize the build by splitting the code so the browser doesn't have to download everything up front.

Expected Behavior

  • The main vendor chunk should be broken down into smaller, more manageable chunks.
  • The build should no longer throw the Some chunks are larger than 800 kB warning.

Proposed Solution

  1. Use Dynamic Imports (React.lazy() and Suspense) in the React router setup for heavy routes or components that aren't needed on the initial page load.
  2. Configure build.rollupOptions.output.manualChunks in vite.config.ts to explicitly split heavy third-party dependencies (like monaco-editor, framer-motion, @tanstack/react-query, etc.) into their own separate chunks.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions