withConfigurations

1import { withConfigurations } from '@ng-rsbuild/plugin-angular'; 2

The withConfigurations function is used to create a Rsbuild configuration object setup for Angular applications that use multiple configurations.

The first argument 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 rsbuildConfigOverrides to be used for that configuration.

PluginAngularOptions

To learn more about the options available when configuring the plugin, see the createConfig API reference.

The final argument is the environment variable to use to determine which configuration to use. The default is NGRS_CONFIG.

1function withConfigurations( 2 defaultOptions: { 3 options: Partial<PluginAngularOptions>; 4 additionalConfig?: Partial<RsbuildConfig>; 5 }, 6 configurations: Record< 7 string, 8 { 9 options: Partial<PluginAngularOptions>; 10 additionalConfig?: Partial<RsbuildConfig>; 11 } 12 >, 13 configEnvVar?: string 14); 15

Examples

The following example shows how to create a default configuration with a production configuration:

myapp/rsbuild.config.ts
1import { withConfigurations } from '@ng-rsbuild/plugin-angular'; 2 3export default withConfigurations( 4 { 5 options: { 6 browser: './src/main.ts', 7 server: './src/main.server.ts', 8 ssrEntry: './src/server.ts', 9 }, 10 rsbuildConfigOverrides: { 11 plugins: [pluginSass()], 12 }, 13 }, 14 { 15 production: { 16 options: { 17 fileReplacements: [ 18 { 19 replace: './src/environments/environment.ts', 20 with: './src/environments/environment.prod.ts', 21 }, 22 ], 23 }, 24 }, 25 } 26); 27