API Reference
withConfigurations
import { withConfigurations } from '@ng-rsbuild/plugin-angular';
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.
The final argument is the environment variable to use to determine which configuration to use. The default is NGRS_CONFIG
.
function withConfigurations(defaultOptions: {
options: Partial<PluginAngularOptions>,
additionalConfig?: Partial<RsbuildConfig>
}, configurations: Record<string, {
options: Partial<PluginAngularOptions>,
additionalConfig?: Partial<RsbuildConfig>
}>, configEnvVar?: string
)
Examples
With Production Configuration
The following example shows how to create a default configuration with a production configuration:
rsbuild.config.ts
import { withConfigurations } from '@ng-rsbuild/plugin-angular';
export default withConfigurations({
options: {
browser: './src/main.ts',
server: './src/main.server.ts',
ssrEntry: './src/server.ts',
},
rsbuildConfigOverrides: {
plugins: [pluginSass()],
},
}, {
production: {
options: {
fileReplacements: [
{
replace: './src/environments/environment.ts',
with: './src/environments/environment.prod.ts',
},
],
},
}
});