Skip to content

Optimized Nx Monorepo Configuration for React & Vite Projects#384

Closed
AditiChauhan19 wants to merge 1 commit into
WordPress:trunkfrom
AditiChauhan19:patch-1
Closed

Optimized Nx Monorepo Configuration for React & Vite Projects#384
AditiChauhan19 wants to merge 1 commit into
WordPress:trunkfrom
AditiChauhan19:patch-1

Conversation

@AditiChauhan19
Copy link
Copy Markdown

✅ Key Changes

Added "serve" to cacheableOperations.

Added "sharedGlobals" with tsconfig.base.json and .env.

Separated development input (ready if you want faster dev builds).

Added shared ESLint config in lint inputs.

Added vitest.config.ts to test inputs.

Apps and libs folder separated (apps vs packages).

Enabled routing: true in React generator for new apps.

##What?

This PR updates and optimizes the Nx monorepo configuration (nx.json) for React and Vite projects. Key improvements include:

-Enhanced caching for build, lint, test, e2e, and serve operations.

-Added shared global inputs (tsconfig.base.json, .env) for proper cache invalidation.

-Separate development and production inputs for faster local builds.

-Updated lint and test targets to include shared configs and Vitest.

-React generator now supports routing by default.

##Why?

This PR is necessary to improve developer productivity and maintainability of the monorepo. It solves the following issues:

-Inefficient caching in Nx tasks.

-Missing shared configurations causing unnecessary rebuilds.

-Lack of default routing setup in React apps.

-Limited test runner inputs, causing stale or inconsistent test results.

##How?

-Updated tasksRunnerOptions with serve added to cacheableOperations.

-Added sharedGlobals to track changes in global config files.

-Defined separate development and production inputs for build targets.

-Included shared ESLint and Vitest configs in lint and test targets.

-Updated workspaceLayout to separate apps (apps) and libs (packages).

-Enabled routing in React app generator.

-Testing Instructions

Check out the branch:

git fetch origin
git checkout

Run build, lint, and test commands:

nx build
nx lint
nx test
nx e2e
nx serve

Verify that caching works as expected and new apps are generated with routing enabled:

nx generate @nx/react:application test-app

Confirm that changes to .env or tsconfig.base.json invalidate caches correctly for all projects.

✅ Key Changes

Added "serve" to cacheableOperations.

Added "sharedGlobals" with tsconfig.base.json and .env.

Separated development input (ready if you want faster dev builds).

Added shared ESLint config in lint inputs.

Added vitest.config.ts to test inputs.

Apps and libs folder separated (apps vs packages).

Enabled routing: true in React generator for new apps.
@adamziel
Copy link
Copy Markdown
Collaborator

adamziel commented Sep 24, 2025

What problem does this PR solve? It seems AI generated so I'll close it. I'm happy to reopen if it improves something relevant.

@adamziel adamziel closed this Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants