nx/docs/shared/guides/angular-rspack/handling-configurations.md
Jack Hsu 28b48ad1f3
docs(misc): update URls that should point to intro pages rather than API index pages (#31531)
This PR fixes an issue introduced when we removed `/nx-api` pages:
https://github.com/nrwl/nx/pull/31453.

Most of the old `/nx-api/<plugin>` URLs should now go to
`/technologies/<plugin>/introduction`, since those pages contain what
was on the previous "overview" pages.

The only exception are places where we explicitly link to
`.../api/{generators,executors,migrations}` URLs, and the following
three blog posts that we want users to land on the API index.

-
https://github.com/nrwl/nx/blob/master/docs/blog/2022-03-29-the-react-cli-you-always-wanted-but-didnt-know-about.md?plain=1#L132
(https://nx.dev/blog/the-react-cli-you-always-wanted-but-didnt-know-about)
-
https://github.com/nrwl/nx/blob/master/docs/blog/2022-04-08-what-is-new-in-nx-13-10.md?plain=1#L245
(https://nx.dev/blog/what-is-new-in-nx-13-10)
-
https://github.com/nrwl/nx/blob/master/docs/blog/2022-05-02-nx-v14-is-out-here-is-all-you-need-to-know.md?plain=1#L253
(https://nx.dev/blog/nx-v14-is-out-here-is-all-you-need-to-know)
2025-06-10 15:08:29 -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