nx/docs/shared/guides/angular-rspack/handling-configurations.md
Jack Hsu 66eaf2fc74
docs(misc): remove /nx-api pages (#31453)
This PR removes the `/nx-api` pages from `nx-dev`. They are already
redirected from `/nx-api` to either `/technologies` or
`/reference/core-api` URLs.

e.g. `/nx-api/nx` goes to `/reference/core-api/nx` and `/nx-api/react`
goes to `/technologies/react/api`

**Changes**:
- Remove old `nx-api.json` from being generated in
`scripts/documentation/generators/generate-manifests.ts` -- this was
used to generate the sitemap
- Remove `pages/nx-api` from Next.js app since we don't need them
- Remove workaround from link checker
`scripts/documentation/internal-link-checker.ts` -- the angular
rspack/rsbuild and other workarounds are gone now that they are proper
docs in `map.json`
- Update Powerpack/Remote Cache reference docs to exclude API documents
(since they are duplicated in the Intro page) --
`nx-dev/models-document/src/lib/mappings.ts`
- All content in `docs` have been updated with new URL structure

**Note:** Redirects are already handled, and Claude Code was used to
verify the updated `docs/` URLs (see report below). The twelve 404s
links were updated by hand.

## Verification Report

https://gist.github.com/jaysoo/c7863fe7e091cb77929d1976165c357a
2025-06-04 16:57:01 -04:00

2.5 KiB

title description
Handling Configurations Guide on how to handle configurations with Angular Rspack

Handling Configurations

Configurations are handled slightly differently compared to the Angular CLI. Rsbuild and Rspack use mode instead of configurations to handle different environments by default. This means that a different solution is needed to handle different build configurations you may have to match the behavior of Angular's configuration handling.

The createConfig function helps you to handle this. It uses the NGRS_CONFIG environment variable to determine which configuration to use. The default configuration is production.

{% callout type="info" title="Roll your own" %} You can handle configurations by yourself if you prefer, all you need is some manner of detecting the environment and then merging the options passed to createConfig. {% /callout %}

Using createConfig for configurations

The createConfig function takes two arguments, the first is the default options, and the second is an object of configurations. The configurations object is keyed by the name of the configuration, and the value is an object with the options and rspackConfigOverrides | rsbuildConfigOverrides to be used for that configuration.

import { createConfig } from '@nx/angular-rspack';
export default createConfig(
  {
    options: {
      browser: './src/main.ts',
      server: './src/main.server.ts',
      ssrEntry: './src/server.ts',
    },
    rspackConfigOverrides: {
      mode: 'development',
    },
  },
  {
    production: {
      options: {
        fileReplacements: [
          {
            replace: './src/environments/environment.ts',
            with: './src/environments/environment.prod.ts',
          },
        ],
      },
    },
  }
);

The above example shows how to handle the production configuration. The options are the same as the default options but with the fileReplacements property added, and the rspackConfigOverrides are the same as the default rspackConfigOverrides.

The NGRS_CONFIG environment variable is used to determine which configuration to use. If the environment variable is not set, the production configuration is used by default. If a production configuration is not provided, the default configuration is used.

To run the build with the production configuration:

NGRS_CONFIG=production npx myapp build