Skip to content
import { createConfig } from '@nx/angular-rsbuild';

The createConfig function is used to create an Rsbuild configuration object setup for Angular applications.

It takes an optional RsbuildConfig object as an argument, which allows for customization of the Rsbuild configuration.

async function createConfig(
defaultOptions: {
options: PluginAngularOptions;
rsbuildConfigOverrides?: Partial<RsbuildConfig>;
},
configurations: Record<
string,
{
options: Partial<PluginAngularOptions>;
rsbuildConfigOverrides?: Partial<RsbuildConfig>;
}
> = {},
configEnvVar = 'NGRS_CONFIG'
);

The following example shows how to create a configuration for a SSR application:

myapp/rsbuild.config.ts
import { createConfig } from '@nx/angular-rsbuild';
export default createConfig({
options: {
browser: './src/main.ts',
server: './src/main.server.ts',
ssrEntry: './src/server.ts',
},
});

The PluginAngularOptions object is an object that contains the following properties:

export interface PluginAngularOptions extends PluginUnsupportedOptions {
aot?: boolean;
assets?: AssetElement[];
browser?: string;
commonChunk?: boolean;
devServer?: DevServerOptions;
extractLicenses?: boolean;
fileReplacements?: FileReplacement[];
index?: IndexElement;
inlineStyleLanguage?: InlineStyleLanguage;
namedChunks?: boolean;
optimization?: boolean | OptimizationOptions;
outputHashing?: OutputHashing;
outputPath?:
| string
| (Required<Pick<OutputPath, 'base'>> & Partial<OutputPath>);
polyfills?: string[];
root?: string;
scripts?: ScriptOrStyleEntry[];
server?: string;
skipTypeChecking?: boolean;
sourceMap?: boolean | Partial<SourceMap>;
ssr?:
| boolean
| {
entry: string;
experimentalPlatform?: 'node' | 'neutral';
};
stylePreprocessorOptions?: StylePreprocessorOptions;
styles?: ScriptOrStyleEntry[];
tsConfig?: string;
useTsProjectReferences?: boolean;
vendorChunk?: boolean;
}
export interface DevServerOptions extends DevServerUnsupportedOptions {
port?: number;
ssl?: boolean;
sslKey?: string;
sslCert?: string;
proxyConfig?: string;
}
export interface OptimizationOptions {
scripts?: boolean;
styles?: boolean;
fonts?: boolean;
}
export type OutputHashing = 'none' | 'all' | 'media' | 'bundles';
export type HashFormat = {
chunk: string;
extract: string;
file: string;
script: string;
};
export interface OutputPath {
base: string;
browser: string;
server: string;
media: string;
}
export type AssetExpandedDefinition = {
glob: string;
input: string;
ignore?: string[];
output?: string;
};
export type AssetElement = AssetExpandedDefinition | string;
export type NormalizedAssetElement = AssetExpandedDefinition & {
output: string;
};
export type ScriptOrStyleEntry =
| string
| {
input: string;
bundleName?: string;
inject?: boolean;
};
export type GlobalEntry = {
name: string;
files: string[];
initial: boolean;
};
export type IndexExpandedDefinition = {
input: string;
output?: string;
preloadInitial?: boolean;
};
export type IndexElement = IndexExpandedDefinition | string | false;
export type IndexHtmlTransform = (content: string) => Promise<string>;
export type NormalizedIndexElement =
| (IndexExpandedDefinition & {
insertionOrder: [string, boolean][];
transformer: IndexHtmlTransform | undefined;
})
| false;
export interface SourceMap {
scripts: boolean;
styles: boolean;
hidden: boolean;
vendor: boolean;
}
export type InlineStyleExtension = 'css' | 'scss' | 'sass' | 'less';
export interface FileReplacement {
replace: string;
with: string;
}
export interface StylePreprocessorOptions {
includePaths?: string[];
sass?: Sass;
}
export interface Sass {
fatalDeprecations?: DeprecationOrId[];
futureDeprecations?: DeprecationOrId[];
silenceDeprecations?: DeprecationOrId[];
}

boolean default: true Enables or disables Ahead-of-Time compilation for Angular applications.

AssetElement[] Array of static assets to include in the build output. Can be either a string path or an object with glob patterns.

string The entry point file for the browser bundle (e.g., 'src/main.ts').

boolean default: true Controls whether to create a separate bundle containing shared code between multiple chunks.

DevServerOptions RsbuildConfig options for the development server including port, SSL settings, and proxy configuration.

boolean default: false When true, extracts all license information from dependencies into a separate file.

FileReplacement[] List of files to be replaced during the build process, typically used for environment-specific configurations.

IndexElement Configuration for the index.html file. Can be a string path, an object with specific settings, or false to disable.

InlineStyleLanguage Specifies the default language to use for inline styles in components.

boolean default: true When true, generates named chunks instead of numerical IDs.

boolean | OptimizationOptions default: true Controls build optimization settings for scripts, styles, and fonts.

OutputHashing default: 'none' Defines the hashing strategy for output files. Can be 'none', 'all', 'media', or 'bundles'.

string | OutputPath Specifies the output directory for built files. Can be a string or an object defining paths for browser, server, and media files.

string[] Array of polyfill files to include in the build.

string The root directory of the project where the rsbuild.config.ts file is located.

ScriptOrStyleEntry[] Array of global scripts to include in the build, with options for bundling and injection.

string The entry point file for the server bundle in SSR applications.

boolean default: false When true, skips TypeScript type checking during the build process.

boolean | Partial<SourceMap> default: true Controls generation of source maps for debugging. Can be boolean or detailed configuration object.

boolean | { entry: string; experimentalPlatform?: 'node' | 'neutral' } Configuration for Server-Side Rendering. Can be boolean or object with specific SSR settings.

StylePreprocessorOptions Options for style preprocessors, including include paths and Sass-specific configurations.

ScriptOrStyleEntry[] Array of global styles to include in the build, with options for bundling and injection.

string Path to the TypeScript configuration file.

boolean default: false Enables usage of TypeScript project references.

boolean default: true When true, creates a separate bundle for vendor (third-party) code.